Create an order through admin API line item price missing

chardzard
Shopify Partner
2 0 2

I'm trying to create an order through the admin REST API, currently just using postman. I'm just doing exactly what is provided in the simple order example, but it seems to not be finding the product to get the relevant information from. I'm using the "id" field for the variant on the product that is being pulled down from the REST API. Below is the POST body, and error response. 

 

{
    "order": {
        "line_items": [
            {
                "variant_id:": 44969483370799,
                "quantity": 1
            }
        ]
    }
}

 

 

 

{
    "errors": {
        "line_items": [
            "line item price not found, `price` must provided."
        ]
    }
}

 

Replies 2 (2)

chris-sellboost
Shopify Partner
22 3 12

Hi @chardzard this error can be returned if the variant_id not exist.

Regards!

chardzard
Shopify Partner
2 0 2

As mentioned in the post, I'm using the "id" field from the first (and only) variant listed under the product. Is this not the correct ID to be using when creating an order? I don't see any other fields on the product object that seem to be relevant. Below is the product for which I'm trying to create an order, using the "id" field from the first variant object. Is that correct?

"products": [
        {
            "id": 8265564848431,
            "title": "TITLE",
            "body_html": "",
            "vendor": "VENDOR",
            "product_type": "TYPE",
            "created_at": "2023-04-27T11:28:27-04:00",
            "handle": "HANDLE",
            "updated_at": "2023-04-28T10:15:12-04:00",
            "published_at": "2023-04-27T11:28:27-04:00",
            "template_suffix": "",
            "status": "active",
            "published_scope": "web",
            "tags": "TAG",
            "admin_graphql_api_id": "gid://shopify/Product/8265564848431",
            "variants": [
                {
                    "id": 44969483370799,
                    "product_id": 8265564848431,
                    "title": "Default Title",
                    "price": "18.00",
                    "sku": "DT1",
                    "position": 1,
                    "inventory_policy": "deny",
                    "compare_at_price": null,
                    "fulfillment_service": "manual",
                    "inventory_management": "shopify",
                    "option1": "Default Title",
                    "option2": null,
                    "option3": null,
                    "created_at": "2023-04-27T11:28:27-04:00",
                    "updated_at": "2023-04-27T11:57:36-04:00",
                    "taxable": true,
                    "barcode": "",
                    "grams": 0,
                    "image_id": null,
                    "weight": 0.0,
                    "weight_unit": "lb",
                    "inventory_item_id": 47018307322159,
                    "inventory_quantity": 5,
                    "old_inventory_quantity": 5,
                    "requires_shipping": false,
                    "admin_graphql_api_id": "gid://shopify/ProductVariant/44969483370799"
                }
            ],
            "options": [
                {
                    "id": 10484998373679,
                    "product_id": 8265564848431,
                    "name": "Title",
                    "position": 1,
                    "values": [
                        "Default Title"
                    ]
                }
            ],
            "images": [
                {
                    "id": 41116146368815,
                    "product_id": 8265564848431,
                    "position": 1,
                    "created_at": "2023-04-27T11:28:28-04:00",
                    "updated_at": "2023-04-27T11:28:28-04:00",
                    "alt": null,
                    "width": 640,
                    "height": 640,
                    "src": "SRC,
                    "variant_ids": [],
                    "admin_graphql_api_id": "gid://shopify/ProductImage/41116146368815"
                }
            ],
            "image": {
                "id": 41116146368815,
                "product_id": 8265564848431,
                "position": 1,
                "created_at": "2023-04-27T11:28:28-04:00",
                "updated_at": "2023-04-27T11:28:28-04:00",
                "alt": null,
                "width": 640,
                "height": 640,
                "src": "SRC",
                "variant_ids": [],
                "admin_graphql_api_id": "gid://shopify/ProductImage/41116146368815"
            }
        },
        ...
]