Requests.post error| TypeError: post() takes at least 1 argument (1 given)
Requests.post error| TypeError: post() takes at least 1 argument (1 given)
我正在使用 Python 2.7.10 64 位。
在 update_jira_field 方法中,出现以下错误:
TypeError: post() takes at least 1 argument (1 given)
我也尝试了 requests.put()
,json = payload
的组合,同时将有效负载声明为 json,但仍然出现相同的错误。
我不确定我做错了什么,在使用请求模块时从未遇到过这个错误。
import requests
import json
import urllib2
auth = *****
propertKey = 'customfield_13557'
headers = {'Accept':'application/json','Bearer':****'}
def get_jira_real_id(jiraKey):
endpoint = 'https://****.atlassian.net/rest/api/3/issue/{0}'.format(jiraKey)
response = requests.get(endpoint, headers = headers, auth = auth)
if response.status_code == 200:
print "Success getting Jira Id"
response = json.loads(response.text)
return response['id']
def update_jira_field(jiraId,jiraKey):
endpoint = 'https://****.atlassian.net/rest/api/3/issue/{0}'.format(jiraId)
payload = dict({"fields": {"customfield_13557":{"self": "https://****.atlassian.net/rest/api/3/customFieldOption/14915", "value": "Yes", "id": "14915"}}})
response = requests.post(endpoint = endpoint, headers = headers, auth = auth, data = payload)
if response.status_code == 200:
print "Success! Updated", jiraId, jiraKey
jiraList = ['****']
for jiraKey in jiraList:
jiraId = get_jira_real_id(jiraKey)
update_jira_field(jiraId, jiraKey)
print "Done Done Done"
知道为什么会出现此错误吗?我该如何解决?
您尝试传入名为 endpoint
的命名参数,但正确的名称是 url
。如果您将行更改为
,它会起作用
response = requests.post(endpoint, headers = headers, auth = auth, data = payload)
我正在使用 Python 2.7.10 64 位。 在 update_jira_field 方法中,出现以下错误:
TypeError: post() takes at least 1 argument (1 given)
我也尝试了 requests.put()
,json = payload
的组合,同时将有效负载声明为 json,但仍然出现相同的错误。
我不确定我做错了什么,在使用请求模块时从未遇到过这个错误。
import requests
import json
import urllib2
auth = *****
propertKey = 'customfield_13557'
headers = {'Accept':'application/json','Bearer':****'}
def get_jira_real_id(jiraKey):
endpoint = 'https://****.atlassian.net/rest/api/3/issue/{0}'.format(jiraKey)
response = requests.get(endpoint, headers = headers, auth = auth)
if response.status_code == 200:
print "Success getting Jira Id"
response = json.loads(response.text)
return response['id']
def update_jira_field(jiraId,jiraKey):
endpoint = 'https://****.atlassian.net/rest/api/3/issue/{0}'.format(jiraId)
payload = dict({"fields": {"customfield_13557":{"self": "https://****.atlassian.net/rest/api/3/customFieldOption/14915", "value": "Yes", "id": "14915"}}})
response = requests.post(endpoint = endpoint, headers = headers, auth = auth, data = payload)
if response.status_code == 200:
print "Success! Updated", jiraId, jiraKey
jiraList = ['****']
for jiraKey in jiraList:
jiraId = get_jira_real_id(jiraKey)
update_jira_field(jiraId, jiraKey)
print "Done Done Done"
知道为什么会出现此错误吗?我该如何解决?
您尝试传入名为 endpoint
的命名参数,但正确的名称是 url
。如果您将行更改为
response = requests.post(endpoint, headers = headers, auth = auth, data = payload)