Fulfilling a specific product using a http request via Flow

Topic summary

Issue: HTTP Request in Shopify Flow to create a fulfillment via GraphQL returned 400 Bad Request. The body used mutation fulfillmentCreateV2 and targeted a specific FulfillmentOrderLineItem, but the request failed against the endpoint ending in /graphiql.json.

Key causes identified:

  • Incorrect endpoint URL: should be /admin/api/2024-01/graphql.json, not graphiql.json.
  • Potential JSON formatting issues: whitespace/newlines in the request body can invalidate the JSON.

Working approach shared:

  • Use the correct GraphQL endpoint (graphql.json).
  • Provide a compact JSON body for the mutation fulfillmentCreateV2.
  • Build variables.lineItemsByFulfillmentOrder via Liquid in Flow (looping over order.fulfillmentOrders) to supply fulfillmentOrderId values.

Outcome:

  • After updating the URL and using the provided example, the request succeeded.

Status: Resolved. No remaining open questions.

Notes:

  • Shopify Flow is automating an admin GraphQL API call; GraphQL requires the correct endpoint and valid JSON payload.
  • The example relies on Liquid templating in Flow to populate fulfillment order IDs dynamically.
Summarized with AI on January 6. AI used: gpt-5.

Hello,

I’m trying to fulfil a specific product with the http request in flow.

This is what I currently have that doesn’t seem to be working:

Here is the code in the Body:

{
    "query": "mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {
        fulfillmentCreateV2(fulfillment: $fulfillment) {
            fulfillment { id }
             userErrors { field message }
        }
    }",
    "variables": {
        "fulfillment": {
            "lineItemsByFulfillmentOrder": {
                "fulfillmentOrderId": "{{order.id}}",
                "fulfillmentOrderLineItems": {
                    "id": "gid://shopify/FulfillmentOrderLineItem/6604087001287","quantity": 1
                }
            }
        }
    }
}

This is the error I am getting:

The request was unsuccessful
{"status":400,"response_body":"Bad Request","verb":"POST","url":"https://regalrose.myshopify.com/admin/api/2024-01/graphiql.json","request_body":"{ \"query\": \"mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {\n    fulfillmentCreateV2(fulfillment: $fulfillment) {\n        fulfillment { id }\n        userErrors { field message }\n    }}\",\n    \"variables\": {\n        \"fulfillment\": {\n            \"lineItemsByFulfillmentOrder\": {\n                \"fulfillmentOrderId\": \"gid://shopify/Order/5635452141767\",\n                \"fulfillmentOrderLineItems\": {\n                    \"id\": \"gid://shopify/FulfillmentOrderLineItem/6604087001287\",\"quantity\": 1\n                }\n            }\n        }\n    }\n}"}

Any help would be appreciated. Thank you.

Your URL is incorrect. It ends in graphql.json not graphiql.json

You may also have to remove white space from your body fields, as newlines can cause the JSON to be invalid. Here’s an example that works:

{ "query": "mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {  fulfillmentCreateV2(fulfillment: $fulfillment) { fulfillment { id } userErrors { field message }  } }", "variables": { "fulfillment": {  "lineItemsByFulfillmentOrder": [{% for fo in order.fulfillmentOrders %}{ "fulfillmentOrderId": "{{fo.id}}"}{% unless forloop.last %}, {% endunless %}{% endfor %}]}}}

Thank you for your help. I copied your code and changed the url and the request went through fine.