繁体   English   中英

使用 Pytest/Python 在 Azure DevOps 中创建工作项时出错

[英]Error in creation of work-item in Azure DevOps using Pytest/Python

我正在尝试使用 Python 和requests库创建一个工作项。

def test_create_work_item(work_items):
    payload = {
                'op': 'add',
                'path': '/fields/System.Title',
                'value': 'Sample bug'
            }
    pl = json.dumps(payload)
    work_item = work_items.create(body=pl, type='bug')
    assert work_item.status_code == 200

我收到以下错误:

{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException,Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}

相同的机构可以与 Postman 一起使用。 所以不确定这里还需要什么才能让它工作。

我不熟悉 Python.... 检查这个例子: 创建工作项

API 使用一组新字段:

[   
    {
    "op": "add",
    "path": "/fields/System.Title",
    "from": null,
    "value": "Sample task"
    } 
]

在您的情况下,您只使用请求中的一个字段:

{
    'op': 'add',
    'path': '/fields/System.Title',
    'value': 'Sample bug'
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM