user41858
user41858

Reputation: 1

Shopify_GraphQL {"Errors":{"Query":"Required Parameter Missing Or Invalid"}}

When I send a request like below:

{"mutation":"{ fulfillmentCreateV2 ( fulfillment: {lineItemsByFulfillmentOrder: { fulfillmentOrderId: \"gid://shopify/FulfillmentOrder/4895903678719\"}} ) { fulfillment { id } userErrors {message}}"}

I get an error:

{"errors":{"query":"Required parameter missing or invalid"}}

(I'm coding in Java, in the query I got it successfully)

Is there anything missing in the JSON I passed?

My code:

CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost http = new HttpPost(urlStr);
http.addHeader("x-shopify-access-token", access_token);
http.addHeader("Accept", "application/json");
http.addHeader("Content-Type", "application/json");
http.setEntity(new StringEntity(myJson));
HttpResponse response = httpClient.execute(http);

Upvotes: 0

Views: 1289

Answers (1)

TwistedOwl
TwistedOwl

Reputation: 1324

I am not a Java specialist but this is not a valid GraphQL query. Most likely you are missing mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) { part

Here's what it should look like based on documentation:

mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {
  fulfillmentCreateV2(fulfillment: $fulfillment) {
    fulfillment {
      # Fulfillment fields
    }
    userErrors {
      field
      message
    }
  }
}

Upvotes: 1

Related Questions