我正在遵循this question中随附的说明。
我收到以下错误:
The required anti-forgery form field "__RequestVerificationToken" is not present
A已经按照以前的要求添加了Cookie __RequestVerificationToken_L3Rmcw2
。我该如何解决这个问题?
这是我的剧本:
cookies = {
'__RequestVerificationToken': 'XXXXXXXXXX',
'__RequestVerificationToken_L3Rmcw2': 'XXXXXXXXXXXX '
}
json_content = 'Content-Type:application/json'
data = 'Request Body:{"planId":XXXXX, "suiteId":XXXXX, "testPointIds":[XXXXX], "outcome":3}'
tfs_update1 = requests.post('https://server:port/tfs/DefaultCollection/Project/_api/_testManagement/BulkMarkTestPoints',
auth=HttpNtlmAuth(username, password), json=json_content, data=data, cookies=cookies)
print(tfs_update1.content)
您可以使用Azure DevOps Python API使用个人访问令牌和指向Azure DevOps组织的URL建立连接。然后从连接中获取客户端并进行API调用。
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)