Getting 422 Unacceptable Entity error (mentioned in Step 3 below)
These are the steps to get the error:
1) Creating the checkout Object
URL -> POST https://harry-potter.myshopify.com/admin/checkouts.json
HEADERS -> X-Shopify-Access-Token(xxx)
Content-Type(application/json)
BODY -> {
"checkout":{
"email": "asdf@asdf.org",
"line_items": [{
"variant_id": 31134652389,
"quantity": 1
}],
"billing_address": {
"first_name": "Harry",
"last_name": "Potter",
"address1": "4 Privet Drive",
"city": "Little Whinging",
"province_code": "SU",
"country_code": "UK",
"phone": "8444437443",
"zip": "201301"
},
"shipping_address": {
"first_name": "Harry",
"last_name": "Potter",
"address1": "4 Privet Drive",
"city": "Little Whinging",
"province_code": "SU",
"country_code": "UK",
"phone": "8444437443",
"zip": "201301"
},
"requires_shipping": false
}
}
We are getting 202 Accepted code
2) We process transactions on credit cards by relying on a separate card vaulting endpoint. Your app submits the credit card to the vault, and the vault returns a payment session_id that your app can use to create a payment for the credit card.
URL-> POST https://elb.deposit.shopifycs.com/sessions
HEADER-> Content-Type: application/json
Accept: application/json
BODY-> {
"payment": {
"amount": "10.0",
"unique_token": "Harry1233",
"credit_card": {
"number": "4242424242424242",
"month": "12",
"year": "2023",
"verification_value": "256",
"first_name": "Harry",
"last_name": "Potter"
}
}
}
We are getting 200 Ok status code and return the session_id
3) Completing the checkout
URL-> POST https://harry-potter.myshopify.com/admin/checkouts/{checkout_token}/payments.json
checkout_token-> received in first step
HEADERS -> X-Shopify-Access-Token(xxx)
Content-Type(application/json)
Accept(application/json)
BODY->
{
"payment": {
"request_details": {
"ip_address": "111.93.122.70",
"accept_language": "en-US",
"user_agent": "Chrome/54.0.2840.98"
},
"amount": "10.00",
"session_id": {coming from 2nd step above},
"unique_token": "Harry1233"
},
"requires_shipping": false
}
We are getting following 422 Unprocessable Entity every time
{
"errors": {
"session_id": [
{
"code": "invalid",
"message": "is invalid",
"options": {}
}
]
}
}
Why is this "unprocessable"?
Hi @Kevin107 ,
The 422 “Unacceptable/Unprocessable Entity” error could be thrown for many different reasons, such as having an incorrectly formatted input or trying to checkout products which are out of stock. In order for us to help narrow down what might be causing this, would it be possible for you to share the value of the “X-Request-ID” header from Shopify’s 422 status response? With this value I can go through the Shopify platform logs and investigate why exactly this response was sent. If you can’t provide this header value, providing your Shop ID and the approximate time frame when this error occurred will also help too!
@hassain please see the X-Request-Id → 44449aa4-f846-4172-8d0e-6ce064c7aca7
Hey @Kevin107 ,
Thank you for providing the X-Request-ID! From looking through our platform logs, it appears to me that this 422 error is being thrown because when Shopify queries for the session_id provided from your payments.json POST request it is getting a “Resource Not Found” error.
One thing I have observed from our logs that may be causing this error to occur, is that I have noticed that the session_id you are passing through the POST request follows a format of “east-{hashcode}”. Could you test and see what happens if you drop the “east-” component of this string and just pass along the hashcode as the session ID? This may possibly help resolve the issue.
Also if you could provide the value of the “X-Request-ID” header for the POST request to the https://elb.deposit.shopifycs.com/sessions endpoint, that would be helpful too. Thanks!
@hassain
I have tried by removing “east-” from session_id still getting 422 error and below is the response and "X-Request-Id " is “27d70811-68fd-44ce-9998-c183fa73a7cf”
{
"errors": {
"session_id": [
{
"code": "invalid",
"message": "is invalid",
"options": {}
}
]
}
}
https://elb.deposit.shopifycs.com/sessions endpoint i am not getting “X-Request-ID” below are the headers we are getting
Server →nginx
Date →Wed, 20 Nov 2019 05:28:56 GMT
Content-Type →application/json
Transfer-Encoding →chunked
Connection →close
Vary →Accept-Encoding
Access-Control-Allow-Origin →*
Strict-Transport-Security →max-age=31536000; includeSubDomains; preload
P3P →CP="NOI DSP COR NID ADMa OPTa OUR NOR"
Content-Encoding →gzip
For fetching session_id I am sending card details to shopify payment end point then it will return new session_id.
Then I am sending this session_id for completing the checkout API. Everytime I am sending new session_id for checkout API still we are getting 422 error
Hi Jeff,
Today we have tried with the two options to complete the checkout flow
-
If we fill the shipping address and update the shipping line in the checkout api then it is working fine. If we set “requires_shipping = false” and not fill the shipping address then it is giving 422 and if we fill the shipping address for “requires_shipping = false” then it is working fine. So in every case we have to fill the shipping address.
-
If I set “requires_shipping = false” in checkout then it should not ask me for the shipping address and still it is giving 422 error.
As per our requirement we don’t need the shipping so we are trying with “requires_shipping = false” and according to doc we have options if we want shipping included in the checkout process or not, for it we have an extra parameter given below
| requires_shipping READ-ONLY |
<br>"requires_shipping": true<br>Whether the checkout requires shipping. If true, then shipping_line must be set before creating a payment. |
|---|
can you please confirm if we set requires_shipping = false then why we need shipping line.
When we create order by checkout api while enabling shopify payment then order is displaying in orders tab of store admin but if we do same thing by enabling stripe payment then the order checkout api is completed but it doesn’t show in the order’s tab.
@hassain Also when payment is completed the how we will check that payment is processed successfully
Hi @Kevin107 ,
when payment is completed the how we will check that payment is processed successfully
One possible solution is make a GET request to the Shopify Admin API endpoint of “/admin/api/2019-10/orders/#{order_id_of_completed_payment}.json”, and then check the field of “financial_status” in the JSON response you will get from this request. If the “financial_status” is set to authorized or paid, then you would that they payment has been processed successfully.
When we create order by checkout api while enabling shopify payment then order is displaying in orders tab of store admin but if we do same thing by enabling stripe payment then the order checkout api is completed but it doesn’t show in the order’s tab
That is very strange behaviour - all completed orders should appear in the orders tab regardless of which payment gateway was used. Can you provide specifics which might help us investigate why this is happening? (i.e. any relevant X-Request-IDs, Order IDs, approximate timeframes, etc). Also, can you verify if those orders that do not show up in the Order’s tab appear under the “Abandoned Checkouts” tab?
can you please confirm if we set requires_shipping = false then why we need shipping line.
This is also strange, and may possibly be a bug on our end. Once again, if you can provide any specifics which might help me investigate why this is occurring (i.e. X-Request-IDs, the JSON payload for your admin/api/checkouts POST request, approximate time frames, etc) then that would be extremely helpful. Also, can you verify if you still get a 422 error if you set requires_shipping=false and include “billing_address” information, but do not include any “shipping_address” information?
For require shipping false here is request id
X-Request-Id →71b5a173-f403-4ebc-8933-9848ca944f5a
Request Body
{
"checkout":{
"email": "akhtar.ali+22@kiwitech.com",
"line_items": [{
"variant_id": 31447125590094,
"quantity": 1
}],
"billing_address": {
"first_name": "Akhtar Test sdfs",
"last_name": "Order",
"address1": "B-9, Sector 3",
"city": "Noida",
"province_code": "UP",
"country_code": "IN",
"phone": "8447737843",
"zip": "201301"
}
},
"requires_shipping": false
}
Response we get
{
"checkout": {
"completed_at": null,
"created_at": "2019-12-04T05:49:01-05:00",
"currency": "USD",
"presentment_currency": "USD",
"customer_id": 2785870577742,
"customer_locale": "en",
"device_id": null,
"discount_code": null,
"email": "akhtar.ali+22@kiwitech.com",
"legal_notice_url": null,
"location_id": null,
"name": "#12114394251342",
"note": "",
"note_attributes": {},
"order_id": null,
"order_status_url": null,
"order": null,
"payment_due": "10.00",
"payment_url": "https://elb.deposit.shopifycs.com/sessions",
"payments": [],
"phone": null,
"shopify_payments_account_id": "acct_1Ez0WbCNlo40OyHu",
"privacy_policy_url": null,
"refund_policy_url": null,
"requires_shipping": true,
"reservation_time_left": 0,
"reservation_time": null,
"source_identifier": null,
"source_name": "3066999",
"source_url": null,
"subscription_policy_url": null,
"subtotal_price": "10.00",
"shipping_policy_url": null,
"tax_exempt": false,
"taxes_included": false,
"terms_of_sale_url": null,
"terms_of_service_url": null,
"token": "3ca4bd51b8559115f360d96ec8d5d8fb",
"total_price": "10.00",
"total_tax": "0.00",
"total_tip_received": "0.00",
"total_line_items_price": "10.00",
"updated_at": "2019-12-04T05:49:01-05:00",
"user_id": null,
"web_url": "https://topfantest.myshopify.com/25649152078/checkouts/3ca4bd51b8559115f360d96ec8d5d8fb",
"line_items": [
{
"id": "b7386f19f76952598fcb9c42ad4e9230",
"key": "b7386f19f76952598fcb9c42ad4e9230",
"product_id": 4421075664974,
"variant_id": 31447125590094,
"sku": "",
"vendor": "topfantest",
"title": "Polo T Shirt",
"variant_title": "Medium / Blue",
"image_url": "https://cdn.shopify.com/s/files/1/0256/4915/2078/products/download_3.jpg?v=1575438326",
"taxable": false,
"requires_shipping": true,
"gift_card": false,
"price": "10.00",
"compare_at_price": null,
"line_price": "10.00",
"properties": {},
"quantity": 1,
"grams": 0,
"fulfillment_service": "manual",
"applied_discounts": []
}
],
"gift_cards": [],
"tax_lines": [],
"tax_manipulations": [],
"shipping_line": null,
"shipping_rate": null,
"shipping_address": null,
"credit_card": null,
"billing_address": {
"id": 5497545130062,
"first_name": "Akhtar Test sdfs",
"last_name": "Order",
"phone": "8447737843",
"company": null,
"address1": "B-9, Sector 3",
"address2": null,
"city": "Noida",
"province": "Uttar Pradesh",
"province_code": "UP",
"country": "India",
"country_code": "IN",
"zip": "201301"
},
"applied_discount": null
}
}
still we are getting require “requires_shipping”: true
Hey @akhtarkiwi ,
As per the official documentation for the Shopify Checkout API, the “requires_shipping” field is a “READ-ONLY” setting. This means you cannot set, change, or update the value of “requires_shipping” field through this API, you can only read it. So even if you pass in “requires_shipping” as false in your payload for the create Checkout POST request, the API will not accept this input.
The “requires_shipping” field will be set to false if and only if all the products in the line items of the checkout are set up as non-physical items that do not need to be shipped. To set this up for a product, go to your Shopify Store’s admin page (i.e. sample-test-store.myshopify.com/admin), and in the left hand side of the screen go to Products → select the product you want to update —> Scroll down to “shipping” —> Uncheck the option for “This is a physical product". Now when you create a new checkout for this product via the Checkout API POST request, you will see that “requires_shipping” will always be false.
If your items are physical products but they do not need to be shipped (i.e. they are picked up by customers locally), then another option could be to set-up a new manual shipping rate for free shipping (read how to do that here). Now when you create the new Checkout POST request, in the payload you can specify this free shipping rate. You will still need to include the “shipping_address” in the payload and “require_shipping” will still default to true, but at least there will not be an additional charge for shipping.
@hassain Ok, got it.
I have one question regarding calculation of shipping cost for draft order.
For draft order if we have to add shipping_line
"shipping_line": {
"handle": "shopify-Standard%20Shipping-8.00",
"price": 0.0,
"title": "Free Shipping"
}
I am unable how we find this handle, but i am able to get all carrier services of the stores by using below api
/admin/api/2019-10/carrier_services.json
Can you please help me in this
Hey @akhtarkiwi ,
I believe this endpoint should hopefully help you get what you are looking for:
https://help.shopify.com/en/api/reference/sales-channels/checkout#shipping_rates-2019-10
Let me know if this helps or not!
@hassain Yes we can find shipping rates, but we have to created a checkout for it. I want to know that is there an api to calculate these shipping rates for draft order? We don’t want to create a checkout then fetch the shipping rates.
As in shop admin we can attach shipping rates to draft order. Please see the attached screenshots
@hassain
When i am creating checkout i am getting “Checkout System disabled” error and code is “403”.
below are the info you might required
X-Request-ID → 28a944d0-4132-48ca-bbea-3cb415bf02f3
Store is → topfantest.myshopify.com
Its urgent can you please check what is the reason for it
Could you share the code you are using to make that second request? I am getting a 422 error on that one.

