0

We actuly update xray test cases by doing a curl with JIRA username and password.

curl -H "Content-Type: application/json" -X POST -u JIRAUSERNAME:JIRAPASSWORD --data @"reports/cucumber.json" https://my.jira-url.com/rest/raven/1.0/import/execution/cucumber

Is there a way to use jira api tocken or some other kind of API key to avoid using username:password ?

soung
  • 1,411
  • 16
  • 33

1 Answers1

1

If you're using Jira server/datacenter, Personal Access Tokens are now possible, as of Jira v8.14.

In terms of syntax, after creating the token, you can use it in your HTTP request using the "Authorization" header, having the value "Bearer <personal_access_token>" In terms of a "curl" request it would be something like

curl -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer <your_personal_access_token>"  https://my.jira-url.com/rest/raven/1.0/import/execution/cucumber

You can also see ahead a screenshot using RestMan.

RestMan example using a personal access token

Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • meanwhile we have updated the official docs at: https://docs.getxray.app/display/XRAY/REST+API – Sérgio Jan 18 '21 at 10:41
  • thank you Sérgio We are using an older version of jira. Is there a workaround for the older versions ? – soung Jan 18 '21 at 17:19
  • The cloud version https://docs.getxray.app/display/XRAYCLOUD/REST+API, I notice wee can use Client Id and a Client Secret for authentication. This isn't available for the jira server? – soung Jan 18 '21 at 17:56
  • 1
    Xray server/DC REST API is built on top of Jira's REST API. Xray Cloud has its own infrastructure, therefore it provides slightly different capabilities. Authentication based on client_id+client_secret is thus only available in Xray Cloud. My only recommendation is to update to a recent version (v8.14) of Jira, so you can take advantage of tokens. – Sérgio Jan 19 '21 at 09:25
  • Creating a token in JIRA just gives one string, it doesn't provide you with client_id and client_secret. How to use the token only for a Test Execution item in JIRA? – Alichino Nov 01 '21 at 11:02
  • Client ID and client secret are some settings in Xray Cloud for Xray ApI Keys. These are not related with jora tokens whatsoever. – Sérgio Nov 01 '21 at 11:07
  • Xray client ID and client secret are only used in Xray cloud – Sérgio Nov 01 '21 at 11:15