Пожалуйста, помогите мне преобразовать приведенный ниже код в Python.
var xhttp = new XMLHttpRequest();
xhttp.open("POST","http://instance.salesforce.com/...", true)
xhttp.setRequestHeader("Authorization", "OAuth <SESSION_ID>")
xhttp.setRequestHeader('Accept',"application/json");
testObject = [{"className":"TestVerifyDate","testMethods": ["testMethod1","testMethod2", "testMethod3"]}]
requestObject = json.stringify(testObject);
response = xhttp.send(requestObject)
response = JSON.parse(response)
Я пытался конвертировать в Python.Ниже приведен код.
import urllib2
from urllib2 import Request, urlopen
import json
values =[{"className":"TestVerifyDate","testMethods": ["testMethod1","testMethod2","testMethod3"]}]
values = json.dumps(values).encode('utf8')
your_url="http://instance.salesforce.com/services/data/v44.0/tooling/"
req = Request(your_url, data=values,headers={'content-type':'application/json'})
response_body = urlopen(req).read()
print response_body
Не знаете, как установить заголовок для авторизации?