Search code examples
seleniumautomationjirajira-rest-apijira-xray

How to import json report through automation using REST API and XRay for JIRA and Cucumber + Xray


I can manually import execution result(report.json) through jira and its giving proper status.But i want to achieve through automation i am unable to do so

enter image description here

How to do so

i tried using below curl command in terminal ..was unable to get expected result

curl -H "Content-Type: application/json" -X POST -u username:password --data @report.json http://myurl.net/rest/raven/1.0/import/execution/cucumber

Solution

  • Note that the curl request you showed is tailored for Xray on Jira server and from the screenshot you're showing, it seems that you're using Xray on Jira Cloud. That requires that you have a token that you need to obtain first of all using another request. If you're doing it by "hand" (i.e. from the command line), you would need to so something like:

    token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
    curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token"  --data @"report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
    

    My cloud_auth.json is something like:

    { "client_id": "215FFD69....","client_secret": "1c00f8f2c..." }
    

    Please check in more detail the authentication API and the endpoint for importing cucumber results (there are two actually) in the cloud.