1

Likely a fringe case, but one that took a few days to track down.

If you get the following error response from the GraphQL UI:

"Error": "Response not Successful: Received Status Code 400"

and you have already been through the process of confirming that your API Key is valid, stored in the target DB, accessible to the current user, etc. then this might help.

We found that this error can mask a response from the CM instance (assuming you're deploying to containers) if you open a terminal to the container from within Docker Desktop and attempt to curl the GQL endpoint...

curl http://localhost/[your GQL endpoint]?sc_apikey=[your API Key Guid] 

and you get this response...

"Message": "Provided SSC API Key is not valid"

You may have a browser extension that is interfering with the request.

We didn't spot any difference in the request headers between instances and decompiling the assemblies didn't immediately reveal the source of the error message, but it did reveal that Sitecore is looking for the API Key in a ViewState object, which is how we ended up suspecting the browser configuration.

Hopefully, this helps someone else on their headless journey!

2
  • Can you split the question and the answer to make it clear to people that you have found your own solution? And maybe elaborate a bit on the browser extension.
    – Gatogordo
    Commented Feb 21, 2023 at 8:02
  • Please split your question and answer as mentioned. Self answered questions are a great addition to SSE
    – Richard Seal
    Commented Feb 21, 2023 at 14:37

2 Answers 2

0

To fix graphql service related issue, need to do following thing.
Need to add APIKey, as in the below image, APIKey item path is /sitecore/system/Settings/Services/API Keys/apikeyitem and we need to use item id of this item as a API Key, and update all required fields as in the image.

enter image description here

To access graphql ui, need to use this endpoint.

https://site.dev.local/sitecore/api/graph/items/master/ui?sc_apikey={FB619FF5-84B4-4904-A8B6-161ADC17DC2B}

Need to enable Sitecore.Services.GraphQL.Content.Master.config

Here is the link for sitecore doc reference to configure graphql ui https://doc.sitecore.com/xp/en/developers/hd/210/sitecore-headless-development/start-using-sitecore-graphql-api.html

I hope this will help.

1
  • Thanks Praveen, we had already been through these steps. I wanted to share this post more as an edge case solution for others rather than a direct question. I’m sure having additional context in this thread will help someone else with one of the other 400 errors that can come up. Cheers! Commented Feb 20, 2023 at 18:52
0

When I changed the host URL to the headless app URL. It worked for me.

This - https://headless.local/sitecore/api/graph/edge/ui?sc_apikey={61654FCF-8DA9-4E14-A095-0DBA32292DA5}

Not this - https://sc102sc.dev.local/sitecore/api/graph/edge/ui?sc_apikey={61654FCF-8DA9-4E14-A095-0DBA32292DA5}

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.