使用带有REST API的python将TFS测试用例状态更新为PASS / FAIL

问题描述 投票:0回答:1

我正在遵循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)
python rest tfs python-3.8
1个回答
0
投票

您可以使用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)
© www.soinside.com 2019 - 2024. All rights reserved.