Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: REST API Internal Error - Unprocessable Entity

REST API Internal Error - Unprocessable Entity

abishekrs
Shopify Partner
25 3 8

I have the following order data that I pass to the Create Order endpoint and I get the below error from Shopify

 

 

{
  "order": {
    "buyer_accepts_marketing": false,
    "cancel_reason": null,
    "email": "john.doe@comcast.net",
    "financial_status": "paid",
    "name": "#189586",
    "note": null,
    "phone": null,
    "processed_at": "2021-10-19T10:47:05-04:00",
    "tags": "revy-upsell-sale,old_store_import",
    "tax_lines": [],
    "taxes_included": false,
    "billing_address": {
      "first_name": "John",
      "address1": "30 Jfundi Road, 32",
      "phone": null,
      "city": "Brookline",
      "zip": "02445",
      "province": "Massachusetts",
      "country": "United States",
      "last_name": "Doe",
      "address2": "",
      "company": null,
      "latitude": 42.3384648,
      "longitude": -71.1445936,
      "name": "John Doe",
      "country_code": "US",
      "province_code": "MA"
    },
    "fulfillments": [
      {
        "location_id": 61263544343,
        "name": "#189586",
        "service": "manual",
        "status": "success",
        "tracking_company": "USPS",
        "tracking_number": "92001901755477000737020307",
        "tracking_numbers": [
          "92001901755477000737020307"
        ],
        "tracking_url": "https:\/\/tools.usps.com\/go\/TrackConfirmAction_input?origTrackNum=92001901755477000737020307",
        "tracking_urls": [
          "https:\/\/tools.usps.com\/go\/TrackConfirmAction_input?origTrackNum=92001901755477000737020307"
        ],
        "line_items": [
          {
            "variant_id": 39459745857559,
            "product_id": 6609764876311,
            "sku": "1271862124"
          },
          {
            "variant_id": 39592248082455,
            "product_id": 6642694455319,
            "sku": "00-0"
          },
          {
            "variant_id": 39464446820375,
            "product_id": 6610531221527,
            "sku": "72932169300"
          },
          {
            "variant_id": 39464232353815,
            "product_id": 6610517458967,
            "sku": "92610231700"
          }
        ]
      }
    ],
    "line_items": [
      {
        "title": "Literally Me Coffee Mug",
        "name": "Literally Me Coffee Mug - 11oz",
        "price": "13.95",
        "quantity": 1,
        "taxable": true,
        "variant_id": 39459745857559,
        "product_id": 6609764876311
      },
      {
        "title": "Mystery T-Shirt",
        "name": "Mystery T-Shirt - L \/ Women's",
        "price": "14.95",
        "quantity": 1,
        "taxable": true,
        "variant_id": 39592248082455,
        "product_id": 6642694455319
      },
      {
        "title": "Spilling The Tea Since 1773 Women's T-Shirt",
        "name": "Spilling The Tea Since 1773 Women's T-Shirt - Red \/ L",
        "price": "25.95",
        "quantity": 1,
        "taxable": true,
        "variant_id": 39464447279127,
        "product_id": 6610531221527
      },
      {
        "title": "100% That Witch Women's T-Shirt",
        "name": "100% That Witch Women's T-Shirt - White \/ L",
        "price": "25.95",
        "quantity": 1,
        "taxable": true,
        "variant_id": 39464232517655,
        "product_id": 6610517458967
      },
      {
        "title": "Route Package Protection",
        "name": "Route Package Protection - $0.98",
        "price": "0.98",
        "quantity": 1,
        "taxable": false,
        "variant_id": 39460934877207,
        "product_id": 6609855479831
      }
    ],
    "shipping_address": {
      "first_name": "John",
      "address1": "30 Jfundi Road, 32",
      "phone": null,
      "city": "Doe",
      "zip": "02445",
      "province": "Massachusetts",
      "country": "United States",
      "last_name": "Doe",
      "address2": "",
      "company": null,
      "latitude": 42.3384648,
      "longitude": -71.1445936,
      "name": "John Doe",
      "country_code": "US",
      "province_code": "MA"
    },
    "shipping_lines": [
      {
        "code": "Standard Shipping (approx. 4-8 Days)",
        "discounted_price": "11.90",
        "discounted_price_set": {
          "shop_money": {
            "amount": "11.90",
            "currency_code": "USD"
          },
          "presentment_money": {
            "amount": "11.90",
            "currency_code": "USD"
          }
        },
        "price": "11.90",
        "price_set": {
          "shop_money": {
            "amount": "11.90",
            "currency_code": "USD"
          },
          "presentment_money": {
            "amount": "11.90",
            "currency_code": "USD"
          }
        },
        "source": "shopify",
        "title": "Standard Shipping (approx. 4-8 Days)",
        "tax_lines": [
          {
            "channel_liable": false,
            "price": "0.00",
            "price_set": {
              "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
              },
              "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
              }
            },
            "rate": 0,
            "title": "MA STATE TAX"
          }
        ],
        "discount_allocations": [
          {
            "amount": "11.90",
            "amount_set": {
              "shop_money": {
                "amount": "11.90",
                "currency_code": "USD"
              },
              "presentment_money": {
                "amount": "11.90",
                "currency_code": "USD"
              }
            },
            "discount_application_index": 0
          }
        ]
      }
    ],
    "fulfillment_status": "fulfilled"
  }
}

 

 

 

Error Message

 

 

 Client error: `POST https://store_name_changed.myshopify.com/admin/orders.json` resulted in a `422 Unprocessable Entity` response:\n
      {"errors":{"base":["Internal error"]}}\n

 

 

 

Request Id: d0183717-35f5-470a-9941-0fb7bf743968

 

Could someone from the Shopify Dev Team please advise why this error occurs and how to fix this?

 

Thanks,

Abishek 

Replies 3 (3)

csam
Shopify Staff (Retired)
267 40 51

Hi @abishekrs 

 

A 422 Unprocessable Entity response indicates that there's something in the request that is incorrect or formatted incorrectly. I'm not able to diagnose exactly what the issue is here, but I would suggest using *either* tracking_number or tracking_numbers and tracking_url or tracking_urls. Also, I notice that you have two separate arrays of line_items, which is not an expected format. Hope this is helpful!

 

Regards,

To learn more visit the Shopify Help Center or the Community Blog.

abishekrs
Shopify Partner
25 3 8

Hi @csam 

 

Thanks for the reply. I have tried to add the `tracking_numbers` and `tracking_urls` to the request and I still get the same error. The two lines items that you are looking at in the request are separate.

 

1. The line items are associated with the order itself.

2. The line items that are being fulfilled.

 

Is there any way to know what the error is occurring on the shopify side for it be treated as a 422 unprocessable entity error?

shaswa
New Member
4 0 0

I've seen this error recently too. But if I retry then it succeeds.