testrail-api icon indicating copy to clipboard operation
testrail-api copied to clipboard

Runs _session.runs.add_run() for POST index.php?/api/v2/add_run/{project_id} not working as expected

Open shenhong29 opened this issue 1 year ago • 8 comments

Error message:

[2023-07-29 16:58:07,930][ERROR][_session]: Code: 400, reason: Bad Request url: https://hp-testrail.external.hp.com/index.php?/api/v2/add_run/466, content: b'{"error":"Field :suite_id is a required field."}'

The issue is the suite_id is not required parameter based on https://support.testrail.com/hc/en-us/articles/7077874763156-Runs#addrun, parameter. And the suite_id is provided in the payload. See the payload information next.

The payload is: project id: 466 suite id: 65398 [2023-07-29 16:58:07,720][INFO ][tr_helper]: Create test run: TR Unit test 2023-07-29_16_58_07.715584-07_00 with payload {"suite_id": 65398, "name": "TR Unit test 2023-07-29_16_58_07.715584-07_00", "description": "Test run TR Unit test 2023-07-29_16_58_07.715584-07_00 with defined testcases", "include_all": false, "case_ids": [35076905, 35076906, 35076907, 35076908, 35076909, 35076910, 35076911, 35076912, 35076913, 35076914, 35076915, 35076916, 35076917, 35092638, 35092639, 35092640, 35092641, 35092642]}

The response is: [2023-07-29 16:58:07,930][DEBUG][_session]: Response header: {'Date': 'Sat, 29 Jul 2023 23:58:07 GMT', 'Set-Cookie': 'tr_rememberme=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0, notificationbar=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/index, TS0104937c=01cc51d60f65ceaac8ccb9113c7ed2af29392e494590650e88f91f2816c687d5d132fa55b50c7630762e56a721ee5fd8b5fe216e01ac7687e66780f86fa40eaf200a3288354f4ee1b49b8a875c83435ec1f23f71ab; Path=/, TS01dcc28e=01cc51d60f0e31948020e5072e2a097b000496617890650e88f91f2816c687d5d132fa55b50c7630762e56a721ee5fd8b5fe216e01ac7687e66780f86fa40eaf200a3288356735f90794a3000489e519ab9613244003875726c359c8555bee4dc23636d04a; path=/index, TS98d9ab12029=08bf25d8b7ab2800d8d1f2bc61bed64729797a338741fd022c197bd5e265ad183568f1e636ead9949d74b04b7841d7a5; Max-Age=30; Path=/', 'Content-Length': '48', 'Connection': 'close', 'Content-Type': 'application/json; charset=utf-8', 'P3P': 'CP="{}"'}

FYI, the post request of add_run with the same endpoint and payload documented above works in the POSTMAN session. image

shenhong29 avatar Jul 30 '23 00:07 shenhong29