The remote server returned an error: (422) Unprocessable Entity.

Shopify Partner
11 0 0

I am trying to update tracking information back to shopify using asp.net and c#.

I am sure there is a problem in JSON data but not able to figure it out

 var baseAddress = "https://STORE.myshopify.com/admin/orders/265005495/fulfillments.json";;

                var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
                http.Credentials = GetCredential(baseAddress);
                http.Accept = "application/json";
                http.ContentType = "application/json";
                http.Method = "POST";
                string postData ="{\"fulfillment\":{\"tracking_number\":\"123456789\",\"notify_customer\":true}}";
                string parsedContent = postData;
                ASCIIEncoding encoding = new ASCIIEncoding();
                Byte[] bytes = encoding.GetBytes(parsedContent);

                Stream newStream = http.GetRequestStream();
                newStream.Write(bytes, 0, bytes.Length);
                newStream.Close();

                var response = http.GetResponse();

                var stream = response.GetResponseStream();
                var sr = new StreamReader(stream);
                var content = sr.ReadToEnd();

 

0 Likes
Shopify Partner
11 0 0

More reading about it it looks like more JSON data need to be passed but as per the documentation just 2 parameters passed should also work?

http://docs.shopify.com/api/fulfillment#create

{
  "fulfillment": {
    "tracking_number": "123456789",
    "notify_customer": true
  }
}

Not able to find what is incorrect?

0 Likes
Shopify Staff
Shopify Staff
95 0 6

Hi Neeraj,

What is the response that you are getting back? What is the value of the 'X-Request-Id' header of the response (this can help me figure things out better)?

0 Likes
Highlighted
New Member
3 0 0

i am also facing the same issue for same post url

0 Likes