Shopify Orders Api Error

Tourist
6 0 2

Hello All,

Having trouble creating an order for an existing customer through the Shopify Api.

 

Using Postman I am sending a POST request to: {store with auth}.myshopify.com/admin/orders.json

My JSON formatted request is this:

{
  "order": {
    "line_items": [
      {
        "product_id": 633636847661,
        "quantity": 1
      }
    ],
    "customer": {
      "id": 59850135966
    }
  }
}

This seems to be in line with what the API docs have however I am receiving back this error: 

{
    "errors": {
        "order": [
            "money field cannot be nil"
        ]
    }
}

Any ideas on what could be causing this issue? There is no mention of a money field in the Orders API Docs.

 

Even while sending the standard "Create a simple order with only a product variant ID" from the Api docs I still get the same error.

{
  "order": {
    "line_items": [
      {
        "product_id": 633636847661,
        "quantity": 1
      }
    ]
  }
}

 

1 Like
Shopify Partner
7 0 0

It looks like you'd have to either load existing product data to confirm whether that product has any money attached to it.

0 Likes
Explorer
83 0 24

Hi Matt,

I don't get an error using the same method, check that the variant actually exists because when I removed the product and tried to create the order I got back the same error but when the product was there I didn't get any error and instead of "product_id" try using the variant ID.

0 Likes
Explorer
83 0 24

Here's the response with the product removed

0 Likes
New Member
2 0 0

We've seen the same message several times over the last few days, and I was about to post a question about it when I saw this one. I'm not certain if the product is missing in our case because our error logs didn't include the original request. In any case, it's a confusing message. Is this something that Shopify have changed recently?

0 Likes
Explorer
83 0 24

Hi Simon,

I don't generally work with creating orders, rather gathering them and sending the data to suppliers. However, I don't believe an order can be created with just the product_id, instead the variant_id can be used as noted here in the documentation. I know the error message isn't very clear but to my assumption this means that the price of the product which is tied to the variant_id cannot be null and cannot be read with just the product_id. The three examples below show the JSON sent using just the product_id and using both product_id and variant_id. Using just the product_id will fail with that money field message just like it would if the variant/product did not exist any longer.

 

Returns "money field cannot be nil"

{
  "order": {
    "line_items": [
      {
        "product_id": 528267411510,
        "quantity": 1
      }
    ]
  }
}

 

Both examples below return a created order

Example 1

{
  "order": {
    "line_items": [
      {
        "product_id": 528267411510,
        "variant_id": 6986261266486,
        "quantity": 1
      }
    ]
  }
}

Example 2 

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

 

0 Likes
New Member
2 0 0

Makes sense - thanks. What threw me was the term "money field", when actually it appears to be referring to price. Maybe "price" is a SQL Server "money" field type behind the scenes?

0 Likes
Tourist
6 0 2

Thanks Nick, this solution worked! Even if a product doesn't have variants, the API still requires that you use the variant.id. 

 

1 Like
New Member
3 0 0

Facing the same "money field cannot be nil" error here, even when I include a valid variant ID which has available inventory in my request like so:

 

{"order": {"line_items": [{"variant_id": 16088940052554, "quantity": 1, "product_id": 59139}], "customer": {"first_name": "***", "last_name": "***", "email": "***@gmail.com"}, "email": "***@gmail.com", "shipping_address": {"first_name": "***", "last_name": "***", "address1": "test order", "city": "SFO", "province": null, "zip": 94920, "country": "USA"}}}

 

What does this error mean?  Why is there no documentation?

 

thank you

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1489 68 220

Thanks for the reports, everyone. I've made an issue to track internally with the interest of making this error clearer to API consumers. The issue that you need to be concerned with is the invalid (or not provided) variant_id, and the error message should reflect as much.

 

I'll update this thread when this is resolved.

0 Likes