Why getting product Id and variant Id null in Line item, Even i am passing in payload creating order

HspZapbuild
Shopify Partner
5 0 0

https://shopify.dev/api/admin-rest/2023-01/resources/order#post-orders

Create An Order API

https://your-development-store.myshopify.com/admin/api/2023-01/orders.json

 

Passing Payload with product_id and variant_id as shown in screenshot 1

Screenshot 1Screenshot 1

 

But in response getting null in product_id and variant_id in lines_items  in screenshot 2

 

ScreenshotScreenshot

 

 

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1434 234 488

Hi @HspZapbuild

 

The REST admin API will allow an app to create an order with custom line items. If you are providing product and variant ID values for products/ variants that do not exist on the shop, then it is expected behaviour for the product and variant IDs to be null in the response. 

 

If you create the product variant first, then you can also create orders by simply including the variant ID and quantity, like the fifth example in our documentation on creating orders.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog