Error Code 400 when making GraphQL Mutation HTTP Request

Sl_Shey
Shopify Partner
2 0 0

I'm trying to execute a Graph QL mutation in a flow HTTP request to update a fulfilment item's location. I've tested this in postman successfully several times, but my request fails in Shopify Flow. Here's my code:

 

 

{
"query":"mutation fulfillmentOrderMove($id: ID!, $newLocationId: ID!) { fulfillmentOrderMove(id: $id, newLocationId: $newLocationId) { movedFulfillmentOrder { id status } originalFulfillmentOrder { id status } remainingFulfillmentOrder { id status }     userErrors { field message }  } 
}",
"variables": {
"newLocationId": "gid://shopify/Location/XXXXXXXXX",
"id":"{% for fulfillmentOrders_item in order.fulfillmentOrders %}
  {{fulfillmentOrders_item.id}}
{% endfor %}"
}
}

 

 

 
Headers are:
Key : X-Shopify-Access-Token | Value: : *********
Key: Content-Type |  Value: application/json
URL: https://MYSTORE.myshopify.com/admin/api/2023-01/graphql.json

Replies 3 (3)

Steve_L
Shopify Staff
11 2 3

Hi,

 

I think the problem is that the liquid is padding the "id" variable with a whitespace at the start and end, so it ends up with `"id": " gid://shopify/FulfillmentOrder/xxxxxxxxx "`.

Try removing the indentation and any spacing around the liquid

To learn more visit the Shopify Help Center or the Community Blog.

Sl_Shey
Shopify Partner
2 0 0

Hi Steve,

Thanks for this. I've updated the https request, but it's still unsuccessful.

Here's the error code that I get:

 

{"status":400,"response_body":"Bad Request","verb":"POST",
"url":"https://mxxxxxx3.myshopify.com/admin/api/2023-01/graphql.json",
"request_body":"
{ “query”:“mutation fulfillmentOrderMove($id: ID!, $newLocationId: ID!) { fulfillmentOrderMove(id: $id, newLocationId: $newLocationId) { movedFulfillmentOrder { id status } originalFulfillmentOrder { id status } remainingFulfillmentOrder { id status } userErrors { field message } } }”,
“variables”: { “newLocationId”: “gid://shopify/Location/7xxxxxxxxx5”, “id”:“gid://shopify/FulfillmentOrder/6xxxxxxxx1”}}"}




There's no padding around the "id" variable, but the request still fails.

Steve_L
Shopify Staff
11 2 3

Hey,

 

I'm looking through request logs and I'm seeing errors like:

"None of the items are stocked at the new location" and "Cannot move to the current origin location." returned from the mutation.

 

I'm not too familiar with the fulfilment's api (I work on Flow), but I'd suggest seeing if it's possible to add a condition before the sendhttp action to check if there is stock at the new location, or if the fulfillmentOrder is already being fulfilled from the location. 

To learn more visit the Shopify Help Center or the Community Blog.