2

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
Suryaneel Varshney
  • 85
  • 1
  • 2
  • 13

1 Answers1

3

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.

Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • {"error_description": "Invalid OAuth client credentials", "error": "unauthorized_client"} . i have written correct client id and secret key but me getting such errror' – Suryaneel Varshney Mar 19 '21 at 11:38
  • That answer isn't from Xray. Are you making the HTTP request to the correct url, like https://xray.cloud.xpand-it.com/api/v2/authenticate ? – Sérgio Mar 19 '21 at 11:54
  • yes..same as you mentioned. also i tried curl -H "Content-Type: application/json" -X POST --data '{ "client_id": "32A27E69B0AC4E539C1401643799E8E7","client_secret": "d62f81eb9ed859e11e54356dd8a00e4a5f0d0c2a2b52340776f6c7d6d757b962" }' https://xray.cloud.xpand-it.com/api/v2/authenticate – Suryaneel Varshney Mar 19 '21 at 12:35
  • Try creating a new API key pair (client id + client secret) and try again – Sérgio Mar 19 '21 at 12:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230129/discussion-between-sergio-and-suryaneel-varshney). – Sérgio Mar 19 '21 at 14:01