Jurgen Feuchter
Jurgen Feuchter

Reputation: 604

Getting Error when using POST Orders on Shopify

I'm trying to post a new order which comes from another marketplace. I have all the correct information, but for some reason the POST is not accepting or recognizing the variant_id Im sending. It always returns an error saying I'm missing name, price, and title. I'm not sure why this comes. Here is the array Im sending:

Array
(
    [order] => Array
        (
            [line_items] => Array
                (
                    [0] => Array
                        (
                            [id] => 2147483647
                            [quantity] => 1
                            [price] => 609
                        )

                )

            [customer] => Array
                (
                    [first_name] => Jurgen
                    [last_name] => Feuchter Garcia
                    [email] => [email protected]
                )

            [note] =>  /// ***** ORDEN MERCADOLIBRE ***** /// ID DE ORDEN ML: order_number
            [financial_status] => pending
            [tags] => Array
                (
                    [0] => Orden MercadoLibre
                )

        )

)

And here is the response:

Array
(
    [errors] => Array
        (
            [order] => Array
                (
                    [0] => Line items is invalid
                )

            [line_items] => Array
                (
                    [0] => Name can't be blank
                    [1] => Title can't be blank
                )

        )

)

I've tried using the value name variant_id instead of id, and it asked me for the same information. Any ideas why this might be happening?

Upvotes: 0

Views: 1409

Answers (4)

Er Amit Shukla
Er Amit Shukla

Reputation: 161

[line_items] => Array ( [0] => Name can't be blank 1 => Title can't be blank )

hi @Laurel This error comes from Shopify whenever the passed variant_id not exists on Shopify, It means that the variation is deleted (Either a whole product or a specific variant option) from the store. You can verify that variant exists using Shopify API. I had also faced the same issue with a Few stores, but after passing the updated variant_id, the issue got resolved and an order was created for the correct item.

Upvotes: 0

Jurgen Feuchter
Jurgen Feuchter

Reputation: 604

I actually found out what was wrong, the variant_id was wrong. Apparently if the variant_id is wrong, it tells you that name and title is missing, and if you have it right, it mentions that price line is missing. This is what happened to me. Not totally sure if it works like that, but I got it to work using the correct variant_id and adding pricing for the product.

Upvotes: 2

Abhishek Bharadwaj
Abhishek Bharadwaj

Reputation: 86

Error 1 is displayed because Price is not part of line_items.

Error 2 is however strange because, Name and Title are not compulsory parts of line_items. For e.g. below example would create an order successfully.


    POST /admin/orders.json
    {
      "order": {
        "email": "[email protected]",
        "fulfillment_status": "fulfilled",
        "send_receipt": true,
        "send_fulfillment_receipt": true,
        "line_items": [
          {
            "variant_id": 447654529,
            "quantity": 1
          }
        ]
      }
    }

Upvotes: 0

HymnZzy
HymnZzy

Reputation: 2925

You can't add a price like that and mind that the id pertains to a variant id and not the product id.

Your variant with id 214748364 should already be priced before hand in the Shopify admin dashboard (backend).

Upvotes: 0

Related Questions