私の問題は、私がオンラインで見たものから私が "認証[401]"という応答を得ているということです。私はPythonでRestの呼び出しを介して新しいユーザーを作成しようとしています。私はPython/Restにはかなり新しくなっていますので、私は何かが欠けていると確信しています。 =」 プリント(R)b'stringofstuffPython/Restの認証の問題
import requests
import json
import base64
print("Script Running")
username = ‘UN’
password = ‘PW’
tempString = username + ':' + password
encodedString = base64.b64encode(tempString.encode())
data = {"name": "changeUser", "password": "12345","emailAddress": "[email protected]","displayName": "changeUser","notification" : "false"}
url = "http://myserver.atlassian.net/rest/api/2/user/"
headers = {'Authentication': 'Basic ' + tempString, 'Content-type': 'application/json', 'Accept': 'application/json', 'X-Atlassian-Token': 'no-check' }
print(encodedString)
r = requests.post(url, json.dumps(data), headers)
print(r)
print("Script Ending")
encodedString戻る応答[401]
認証情報が実際のサービスに対して有効であることを確認しましたか? – Andrew
はい。インスタンスに対して認証資格情報を使用できるようになりました。私はスペルミスではないことを確認するためにすべてのスペルをダブルチェックしました – BlueBaroo
curlを使用してクエリを混乱させ、レスポンスを確認することができます。 curl -D- -u UN:PW -X POST -H "Content-Type:application/json" https://myserver.atlassian.net/rest/api/2/user -d '{"name": "このメソッドを使用すると、「changeUser」、「password」:「12345」、「emailAddress」:「[email protected]」、「displayName」:「changeUser」、「notification」:「false」} ' – Jesse