For example,
computer:~ user$ curl -H "Authorization: bearer token" -X POST -d " \ > { \ > \"query\": \"query { viewer { login }}\" \ > } \ > " https://api.github.com/graphql {"data":{"viewer":{"login":"UserName"}}}
However, when I attempt the same query using HTTP
{ "data": null, "errors": [ { "message": "A query attribute must be specified and must be a string." } ] }
Solved! Solved! Go to Solution.
If you're talking about httpie, use piping:
echo '{"query": "{viewer{login}}"}' | http POST https://api.github.com/graphql Authorization:"bearer xxxxxxxxxxxxxx"
It seems there were a couple issues on my end. For example, one difference was that cURL automatically adds the `User-Agent` which one has to add manually using HTTP. I couldn't figure out the issue with R's http, but after making sure the query were properly escaped with HTTP.jl I got it to work.