You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried using this repository to query Github's GraphQL API. But no matter what I do, I keep getting a "Problems parsing JSON" message.
An extracted piece of the code below:
Looking at Chrome's Network tab, I see that the request payload that is being sent is: query=query%20repo(%24name%3A%20String!%2C%20%24owner%3A%20String!)%7Brepository(name%3A%24name%2C%20owner%3A%24owner)%7Bid%7D%7D&variables=%7B%22name%22%3A%22freeCodeCamp%22%2C%22owner%22%3A%22freeCodeCamp%22%7D
I have the same query running on Insomnia and it works. When I convert Insomnia's request to curl, the payload looks like this: --data '{"query":"query repo($name: String!, $owner: String!){\n\trepository(name:$name, owner:$owner){\n\t\tid\t\t\n\t}\n}","variables":{"name":"freeCodeCamp","owner":"freeCodeCamp"},"operationName":"repo"}'
When decoding both strings, it is visible that both payloads have different formats.
Is this an issue with how the repository is creating the payload, is this a mistake on my code, or is this something particular to how Github's API accept the query string?
I have tried using this repository to query Github's GraphQL API. But no matter what I do, I keep getting a "Problems parsing JSON" message.
An extracted piece of the code below:
With this code I always get a HTTP 400 (Bad Request) response. With the following data:
Looking at Chrome's Network tab, I see that the request payload that is being sent is:
query=query%20repo(%24name%3A%20String!%2C%20%24owner%3A%20String!)%7Brepository(name%3A%24name%2C%20owner%3A%24owner)%7Bid%7D%7D&variables=%7B%22name%22%3A%22freeCodeCamp%22%2C%22owner%22%3A%22freeCodeCamp%22%7D
I have the same query running on Insomnia and it works. When I convert Insomnia's request to curl, the payload looks like this:
--data '{"query":"query repo($name: String!, $owner: String!){\n\trepository(name:$name, owner:$owner){\n\t\tid\t\t\n\t}\n}","variables":{"name":"freeCodeCamp","owner":"freeCodeCamp"},"operationName":"repo"}'
When decoding both strings, it is visible that both payloads have different formats.
Is this an issue with how the repository is creating the payload, is this a mistake on my code, or is this something particular to how Github's API accept the query string?
Same question posted on stackoverflow.
The text was updated successfully, but these errors were encountered: