Solved

updating note attributes requires valid shipping address

seshna
Shopify Partner
13 0 1

I have created an order via Admin panel - and by doing it this way you are not required to give a full shipping address. For instance, you can have a blank address1, phone, or city (these fields are required if the order is placed by the customer).

 

Trying to update the note attributes of this order via the ShopifyAPI returns an error -

shipping_address: ["address1 can't be blank and city can't be blank"] 

Just for a bit of background, this is how I'm updating the order (using a rails environment)

shopify_order = ShopifyAPI::Order.find(5437347592)
shopify_attributes = {"Requested Delivery Date"=>"", "Shipping Date"=>"2017/10/16", "Timeslot"=>"", "Special Instructions"=>""}
shopify_order.update_attributes(note_attributes: shopify_attributes)

I find this strange - like it could be a bug. Why would a valid shipping address be required to update note attributes?

 

Accepted Solution (1)

Josh
Shopify Staff
1134 84 234

This is an accepted solution.

Hey @seshna , 

 

It's actually the shopify_api gem that causes this. When it updates an order, it sends every single field when trying to perform the update. So while you may not realize it, you actually are updating the order address while updating note attributes (as well as every other field on the order). Because it then sends an incomplete address to the Order API while doing this, the order address validation kicks in and throws an error instead of letting the update complete. 

 

If you were to perform the same API call with an HTTP client or even just a cURL request, your update would work fine. 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 3 (3)

Josh
Shopify Staff
1134 84 234

This is an accepted solution.

Hey @seshna , 

 

It's actually the shopify_api gem that causes this. When it updates an order, it sends every single field when trying to perform the update. So while you may not realize it, you actually are updating the order address while updating note attributes (as well as every other field on the order). Because it then sends an incomplete address to the Order API while doing this, the order address validation kicks in and throws an error instead of letting the update complete. 

 

If you were to perform the same API call with an HTTP client or even just a cURL request, your update would work fine. 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

seshna
Shopify Partner
13 0 1

Thank you Josh,

I understand - I appreciate you taking the time.

PaskalyaTavsani
Visitor
1 0 0

hello   @Josh   i couldn t  create post  so wrote here im  having some problem  like this  when i try to update shipping address order  with  rest Admin API

order => Required parameter missing or invalid

im getting this error im giving every details correct but my english is not properly good so i coudlnt find a solution can you help me please .