Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;解析JSON的问题;在使用github API和Python请求创建问题时_Json_Python 3.x_Python Requests_Github Api - Fatal编程技术网

&引用;解析JSON的问题;在使用github API和Python请求创建问题时

&引用;解析JSON的问题;在使用github API和Python请求创建问题时,json,python-3.x,python-requests,github-api,Json,Python 3.x,Python Requests,Github Api,当我试图用python请求模块创建问题时,它返回问题{“message”:“解析JSON的问题”,“文档\u url”:”https://developer.github.com/v3“} 以下是我使用的代码: user = <My user> pswd = <My password> ses = requests.Session() ses.auth = (user, pswd) issue = {"title": "Hello World", "bo

当我试图用python请求模块创建问题时,它返回问题
{“message”:“解析JSON的问题”,“文档\u url”:”https://developer.github.com/v3“}

以下是我使用的代码:

user = <My user>
pswd = <My password>
ses = requests.Session()
ses.auth = (user, pswd)
issue = {"title": "Hello World",
         "body": "omg",
         "assignee": <My user>,
         "milestone": None,
"labels": ["label", "friend"]
}
l = json.dumps(issue)
r = ses.post("https://api.github.com/repos/<My user>/<My repo>", params=l)
用户=
pswd=
ses=requests.Session()
ses.auth=(用户,pswd)
问题={“标题”:“你好,世界”,
“身体”:“天哪”,
“受让人”:,
“里程碑”:无,
“标签”:[“标签”、“朋友”]
}
l=json.dumps(问题)
r=ses.post(“https://api.github.com/repos//,参数=l)

当然,我为实际用户和repo替换了
中的内容,出于隐私原因,我将其放在这里使用
json
参数发送json文档并
POST
发送到
/repos/:owner/:repo/issues

import requests
import json

user = "username"
pswd = "password"
repo = "your-repo"

ses = requests.Session()
ses.auth = (user, pswd)

issue = {
    "title": "Hello World",
    "body": "omg",
    "assignee": user,
    "milestone": None,
    "labels": ["label", "friend"]
}

issue_url = "https://api.github.com/repos/" + user + "/" + repo + "/issues"

r = ses.post(issue_url, json = issue)

尝试使用
用户
而不是
我使用我的实际用户和那里的所有东西,出于隐私原因(自然),我放置
,谢谢你的评论,我会澄清的,好的。那么我猜问题来自
None
值。你知道服务器确切地期望什么吗?它期望
里程碑
为int,但当我将其设置为数字时,它也不起作用。其余部分需要一个字符串,
labels
需要一个字符串数组。您正在尝试使用这些字符串吗?如果是这样,您的URL将错过结尾处的
/millements