1

Hi I need to send JSON format through the CURL command but I am getting an error.

curl --request POST "https://app.io/api/graphql?accountId=Xzg" --header "x-api-key: WHpnV=" --header "Content-Type: application/json" --data-raw "{applications(limit: 2) {nodes {name}}}"

So the problematic part is data-raw, although I have checked it online it's Valid JSON.

--data-raw "{applications(limit: 2) {nodes {name}}}"

Response:

{"metaData":null,"resource":null,"responseMessages":[{"code":"DEFAULT_ERROR_CODE","level":"ERROR",
"message":"Unable to process JSON Unexpected character ('a' (code 97)): 
    was expecting double-quote to start field name","exception":null,"failureTypes":[]}]}

I tried different ways how I could change this request data but without success. Can someone please assist me how I should change this query which was definitely generated as the proper one from some app. Thanks!

1
  • 1
    Welcome to Salesforce StackExchange. Please edit your post to describe how your question is related to Salesforce. Oct 12, 2021 at 16:22

1 Answer 1

0

I believe your attempting to send the query via JSON (https://www.contentful.com/developers/docs/references/graphql/#/introduction/http-methods) and so you need to wrap it as a query?

--data-raw '{"query": "{applications(limit: 2) {nodes {name}}}" }'

Not the answer you're looking for? Browse other questions tagged .