1
votes

I developed a web application that uses the Shopify API a while back, it's been running without a problem for about 2 months now, until this week when an error started to occur.

We are trying to update an orders fulfilment using an API call in PHP.

In PHP we POST to the following: http://www.the-web-shop-like-this.com/admin/orders/0123456789/fulfillments.json

We POST the following variable: $fulfillment_update

The variable is set like so:

$fulfillment_update = "
     'fulfillment': { 
        'tracking_number': '',
        'notify_customer': true
            }";

POST'ing the blank tracking_number was to force the shopify system into generating the fulfilment email and for marking that order as fulfilled - no tracking number is ever added and notify_customer is always set to true.

Shopify API comes back (since the weekend) saying: 'Unprocessable Entity'.

Any ideas Ladies & Gents?

Thanks in advance!

1
Is the behavior with having an empty 'tracking_number' to invoke some specific behavior documented or is that a hack on your own? Maybe they just fixed a bug you relied on… - feeela
I was mimicking the way in which you could use the back-end admin panel built into Shopify in that you could just click 'update fulfilment information' and leave the tracking number blank. You could be right in saying they've fixed a bug - The only problem is for people who don't wish to send out tracking information - I have contacted Shopify but they usually take many days to respond. Fingers crossed there is a way around it! - Paul
instead of mimicking something, you should read the API documentation… - feeela
If it helps: api.shopify.com/fulfillment.html - "Modify an existing Fulfillment" -> There is no mention of whether or not either of the variables are required or must be posted/put to do the job ? Does this signify a lack of proper documentation? - Paul
The URL you've specified is lacking a fulfillment id, which is required if you're trying to update a specific fulfillment. That's all I can tell you without the actual shop name and API key you're using. - David Underwood

1 Answers

1
votes

I'm seeing some strange param encoding on your request params. Here's what Rails is getting:

{"_json"=>"'fulfillment': { 'tracking_number': '', 'notify_customer': true}", "order_id"=>"147265452"}

This is a hash with a key '_json' and a value containing the json as a string. This suggests that you're passing your data incorrectly somehow. Can you post the full code you're using to kick off the HTTP request?

P.S.: Are you aware of the existing client libraries for PHP? Here's a list, I highly recommend using one of them unless you have a specific reason not to: http://wiki.shopify.com/Shopify_App_Development#.E2.80.9CI.E2.80.99m_a_PHP_developer.E2.80.9D