2

I am trying to use Graphql playground using the Delivery API endpoint and I am getting an error

{
  "error": "Unexpected end of JSON input"
}

I am using Edge token as an API key.

enter image description here

Can anyone guide me?

Additionally, I have set Sitecore_GraphQL_ExposePlayground="true" in the XM cloud variable tab

2
  • it seems that the JSON input is incomplete or malformed. Please verify it firstly.
    – Alexander
    Aug 16, 2023 at 8:34
  • I have verified it, JSON Input is complete
    – Manoj
    Aug 16, 2023 at 10:31

3 Answers 3

2

Once you’ve generated your token, you need to pass your API Token in the headers for your request. If you look at the bottom of the page you will see a HTTP HEADERS button that will give you a pane used to add those to your request. You add them in the following format,

{
   "X-GQL-Token": "XXX_YOUR_TOKEN_HERE_XXX"
}

Once this has been added you will be able to query your data and see results returned.

Reference:

https://robearlam.com/blog/how-to-set-the-experience-edge-auth-token-with-apollo-graphql

https://konabos.com/blog/querying-sitecore-experience-edge-using-the-graphql-endpoint

Hope it helps!

1

Your url is wrong in your ide. You are trying to query the IDE and not the API. Change the URL to :

https://edge.sitecorecloud.io/api/graphql/v1

Change it here: enter image description here

2
  • Thanks , This resolved the issue
    – Manoj
    Aug 17, 2023 at 13:13
  • If this resolved the issue, can you please mark the answer as accepted so others can benefit too. Thanks.
    – Richard Seal
    Aug 17, 2023 at 15:10
0

Verify that your edge token is valid. Pay attention to the expires_in property of the response because JWTs typically expire in 24 hours. After that time, the token is invalid, and you must request a new token.

I would say to create a new token from Edge and add this to your HTTP Headers.

{
"sc_apikey":"TOKEN HERE"
}

See if this resolves the issue.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.