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

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

问题描述

参考此指南后,我需要访问github graphql 使用 curl 进行测试.我试过这个简单的命令

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

但它给了我

解析 JSON 的问题

problems parsing JSON

我做错了什么.我花了将近 2 个小时试图弄清楚它并尝试了不同的示例,但没有一个起作用.你能帮我解决这个问题吗

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

推荐答案

您只需要将 JSON 中的双引号作为查询进行转义

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天全站免登陆