Search code examples
phpapishopifyfulfillment

Modify an existing Fulfillment unexpectedly returns 404 page


I am currently using sandeepshetty's shopify.php plugin on github https://github.com/sandeepshetty/shopify.php

The plugin appears to work and the logic is fairly simple. I have tested it using the "Create a new Fulfillment", however I get an error message when using the "Modify an existing Fulfillment" API call.

I submit the following string and I receive a 404 error

$orders = $shopify('PUT', "/admin/orders/160387514/fulfillments/791851111396.json", $fulfillment_put, $response_headers);

Where $fulfillment_put translates to the payload

{ "fulfillment": { "tracking_number": "987654321", "id": 255858046 } }

The following is a verbose dump from the PUT command. As can be seen above, I used the following format for the path. I did replace a few variables with either hidden or alt just as an fyi.

/admin/orders/#{order_id}/fulfillments/#{product_id}.json

* About to connect() to alt.myshopify.com port 443 (#0)
*   Trying 204.93.213.40... * connected
* Connected to alt.myshopify.com (204.93.213.40) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /usr/share/curl/curl-ca-bundle.crt
  CApath: none
* SSL connection using RC4-SHA
* Server certificate:
* subject: /serialNumber=Hidden/C=CA/ST=Ontario/L=Ottawa/O=Jaded Pixel Technologies Inc./CN=*.myshopify.com
* start date: 2010-05-10 22:23:08 GMT
* expire date: 2015-08-12 19:17:14 GMT
* subjectAltName: alt.myshopify.com matched
* issuer: /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
* SSL certificate verify ok.
* Server auth using Basic with user 'hidden for privacy'
> PUT /admin/orders/160387514/fulfillments/791851111396.json HTTP/1.1
Authorization: Basic hidden for privacy=
User-Agent: HAC
Host: alt.myshopify.com
Accept: */*
Content-Type: application/json; charset=utf-8
Content-Length: 62

< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Thu, 21 Mar 2013 21:39:06 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Status: 404 Not Found
< X-Shopify-Shop-Api-Call-Limit: 2/500
< HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 2/500
< X-Request-Id: 7ec529327cd022e973f22be4a9e86916
< X-UA-Compatible: IE=Edge,chrome=1
< Set-Cookie: _secure_session_id=hidden; path=/; secure; HttpOnly
< X-Runtime: 0.042757
< 
* Connection #0 to host alt.myshopify.com left intact
* Closing connection #0

P.S. I would like to note that I used the following API documentation http://docs.shopify.com/api/fulfillment#create

It suggests that I use PUT /admin/orders/#{id}/fulfillments/#{id}.json

However, #{id} is referenced in there twice, suggesting that I should use the Order ID twice in a row, but the documentation clearly shows the example of /admin/orders/450789469/fulfillments/255858046.json I would like more clarification on what the actual #{id}'s stand for and how to use them.


Solution

  • I think you're just using the wrong ID for the second one in /admin/orders/#{id}/fulfillments/#{id}.json. You're right about the first one, it's the order ID, but the second one is the fulfillment ID. The fulfillment ID was returned in the create fulfillment response.