【问题标题】:Update TFS test case status to PASS / FAIL using rest api with python使用带有python的rest api将TFS测试用例状态更新为PASS / FAIL
【发布时间】:2020-05-28 11:16:05
【问题描述】:

我正在按照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】:

    您可以使用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)
    

    【讨论】:

      猜你喜欢
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多