curl POST cmd works to post to execution evidence in xray but doesn't work with python requests.post

Suryakant April 15, 2020

Below curl command works if post to execution evidence in Xray and attaching test.log file to evidence field:

curl -H "Content-Type: application/json" -X POST -u user:pwd --data @test.json https://jira.opentv.com/rest/raven/1.0/api/testrun/{id}/attachment

where test.json has this,

{
"data":"VGhpcyBmaWxlIGlzIHRlc3RpbmcgZm9yIHVwbG9hZCB0byBleGVjdXRpb24gZGV0YWlscy4=",
"filename":"test.log",
"contentType":"application/json"
}   (in json 'data' is base64 encoded which is only supported in xray)

but when i try the same with below requests.post it fails. 

requests.post('https://jira.opentv.com/rest/raven/1.0/api/testrun/{id}/attachment',headers = {'Content-Type':'application/json'},data={"data":"VGhpcyBmaWxlIGlzIHRlc3RpbmcgZm9yIHVwbG9hZCB0byBleGVjdXRpb24gZGV0YWlscy4=","fileName":"test.log","Content-Type":"application/json"},auth=('user', 'pwd'))

Thanks in Advance..

the curl cmd is executed from linux machine and python requests.post from windows. Both are reachable to Xray.

1 answer

0 votes
José Domingues [Xray]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 24, 2020

Hi @Suryakant

Curl command works manually. The request works but will fail when using it inside your custom application. 
Since the Xray itself is working, there is not much else we can help as we don't provide support to custom applications.

We do have several code samples (some using Python) which you could use as a reference to build your own application.

Please check the link Tutorials, Tips and Tricks - Automation to get those samples; remember that those samples are provided "as is" and they are not supposed to be used on production and may need adjustments to work on your environment.

Please let us know if you have any questions or issues with Xray through our Service Desk

Best Regards,

Team Xray

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events