Invalid global id and The json provided is not formatted correctly

when i set entity with string:

{“query”:“{ order (id:4895903678719) { id }}”}

I received a respone:

200 OK

“message”:“Invalid global id ‘4895903678719’”

when i set entity with string:

{“query”:“{ order (id:“gid://shopify/Order/4895903678719”) { id }}”}

I received a : {“status”:400,“error”:“The json provided is not formatted correctly: Error occurred while parsing request parameters”}

Where am i going wrong can you guide me?

My sourcre 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”);

HttpEntity entity = new ByteArrayEntity(reqData.getBytes(“UTF-8”));
http.setEntity(entity);
HttpResponse response = httpClient.execute(http);

‘’’

i solved it with request like below:

{“query”:“{ order (id:\"gid://shopify/Order/4895903678719\") { id }}”}

1 Like