Trying to post a fulfillment but error says order is required

Solved
Highlighted
Tourist
3 2 0

I'm following the instructions described here:   https://help.shopify.com/en/api/reference/shipping-and-fulfillment/fulfillment

 

I really want to to follow the instructions under subheader, "Partially fulfill a single line item by specifying a line item and quantity to be fulfilled",   But i tried a few other variations and still get the same errors.

 

I'm using this URL, which includes the order number: 

 

https://MYSTORE.myshopify.com/admin/api/2019-10/orders/#1003/fulfillments.json

 

and this JSON:

 

{
	"fulfillment": {
		"location_id":33498759222,
		"tracking_numbers":["1Z900VV20300002123","1Z900VV20300002124","1Z900VV20300002125"],
		"line_items":[
			{"id":4008663973942,"quantity":3},
			{"id":4008664006710,"quantity":3},
			{"id":4008664039478,"quantity":3}
		]
	}
} 

I've double checked the line ID and Location ID are all valid.  I've tried removing the lines numbers.  Removing the tracking numbers.  I even tried adding an order number to the JSON although that is not called for in the documentation.

 

No matter what i get this error:

 

{
  "errors": {
    "order": "Required parameter missing or invalid"
  }
}

 

I tried doing a get instead of a post.  The get works fine, so i not its not an authentication issue, bad URL or anything like that.

 

The only thing i can think is that the problem relates to the fact that I do the get I get a response for the get.  I get a fulfillment including what appears to be a fulfillment ID.  But through the UI, the order (1003) shows as fulfllment = "Unfulfilled".  See image:OrderStatusInShopify.png

So i thought, whatever, let me try just putting the tracking numbers.  See subheader from my link above called, "Update the tracking number for a fulfillment"

 

URL = https://MYSTORE.myshopify.com/admin/api/2019-10/orders/#1003/fulfillments/#1798642827318.json

Method = PUT

JSON = 

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

You guessed it, same error message: "order": "Required parameter missing or invalid"

 

what the heck am I doing wrong? I feel like i am following the documentation to the letter.

 

if it helps here is my C#

 

public string SendJson(string reasource, string json, RestSharp.Method restRequrest)
{
    string url = MakeUrl(reasource); //I put a breakpoint here and gave you the value from inside the url variable.

    //Build and execute the request
    var client = new RestClient(url);
    var request = new RestRequest(restRequrest);
    client.Authenticator = new HttpBasicAuthenticator(username, password);
    request.AddJsonBody(json); 

    //Transmit Json
    IRestResponse response = client.Execute(request);

    return response.Content;
}

Thanks in advance.

 

 

0 Likes
Highlighted
Tourist
3 2 0

This is an accepted solution.

I was making two mistakes.

 

First, 1001 is my order NAME.  it is not my order ID.  My order ID was the internal key.  Fair enough.  My get wasn't actually working, because i didn't specify a valid order ID it was returning all orders, including orders which had been fulfilled.  So that was confusing me.

 

second, your not actually meant to include the # in the URL.  Which maybe i'm crazy, but the documentation is very misleading in this regard.

 

/admin/api/2019-10/orders/#{order_id}/fulfillments.json

The correct URL is:

 

/admin/api/2019-10/orders/1798642827318/fulfillments.json

 That one i'm a little miffed about.  The documentation should just not include the # symbol.  Or it should be inside the {}s.  

 

I can't believe it so i double checked with using the GET.

 

orders/#1798642827318/fulfillments - returns ALL my orders and all the fulfillments for all my orders.

 

orders/1798642827318/fulfillments - returns nothing, which IMO makers sense because that order is not fulfilled.

 

still getting an error on posting though.  Same JSON as above.

 

{
  "errors": {
    "fulfillment": "Required parameter missing or invalid"
  }
}
0 Likes
Highlighted
Tourist
3 2 0

This is an accepted solution.

I don't know why, but some changes to my C# function fixed the problem

 

            request.AddHeader("Accept", "application/json");
            request.AddParameter("application/json", json, ParameterType.RequestBody);
            //request.AddJsonBody(json);
0 Likes
Highlighted
Shopify Partner
8 0 1

I wonder if there's a trick on how to do a call using 'order number', not the 'order id' ?

 

 

0 Likes