如何使用curl来访问github graphql API [英] How to use curl to access the github graphql API

查看:786
本文介绍了如何使用curl来访问github graphql API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在引用此指南之后,我需要访问github graphql 通过使用 curl 来进行测试。我试过这个简单的命令:

$ curl -i -H授权:承载者myGithubAccessToken-X POST -d'{query :query {repository(owner:wso2,name:product-is){description}}}'https://api.github.com/graphql

但它给我


解析JSON的问题


我做错了什么。我花了近2个小时试图找出它,并尝试了不同的例子,但没有一个能够工作。你可以请客气,帮我解决这个问题。

你只需要转义JSON内的双引号就可以了query

  $ curl -i -H'Content-Type:application / json'-HAuthorization:bearer myGithubAccessToken-X POST -d'{query:query {repository(owner:\wso2 \,name:\product-is \){description}}}'https://api.github .com / graphql 


After referring this guide I needed to access the github graphql by using curl for a testing purpose. I tried this simple command

curl -i -H "Authorization: bearer myGithubAccessToken" -X POST -d '{"query": "query {repository(owner: "wso2", name: "product-is") {description}}"}' https://api.github.com/graphql

but it gives me

problems parsing JSON

what I am doing wrong. I spent nearly 2 hours trying to figure it and tried different examples but none of them worked. Can you please be kind enough help me resolve this

解决方案

You just need to escape the double quotes that are inside the JSON as the query

$ curl -i -H 'Content-Type: application/json' -H "Authorization: bearer myGithubAccessToken" -X POST -d '{"query": "query {repository(owner: \"wso2\", name: \"product-is\") {description}}"}' https://api.github.com/graphql

这篇关于如何使用curl来访问github graphql API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆