XRAY REST API to import unit test results into JIRA - using a Personal Access Token(PAT)

Ajay Taneja January 20, 2023

I have a .yml file in my Gitlab. I'm able to successfully import my unit test results into JIRA using the following curl command which uses the REST API provided. This works very well:

 

    - 'curl -H Content-Type:multipart/form-data -u username:password -F file=@coverage2.xml "https://jira.devops.jlr-apps.com/rest/raven/1.0/import/execution/junit?projectKey=VHST&testPlanKey=VHST-5"'

 

In the above, I was using my username and my password, which was all well.

Now, I do not want to use my user name and password but instead want to use a PAT - personal access token for JIRA.

 

Therefore, I tried this:

 

   - 'curl -H Content-Type:multipart/form-data -H "Authorization: Bearer NzEzMDM5MDc0MDU5OhXdEvd5uQFmcTmMLyV6NWuz78Yk" -F file=@coverage2.xml "https://jira.devops.jlr-apps.com/rest/raven/1.0/import/execution/junit?projectKey=VHST&testPlanKey=VHST-5"'  

 

This is giving me an error as follows:

{"error":"Project does not exist.\nIssue with key \u0027VHST-5\u0027 does not exist or is not of type Test Plan."}

However, my test plan page in JIRA is VHST-5 which does exist

What will be the format of the command when using a Personal Access Token (PAT)? Please can anyone advise?

 

Thanks

 

1 answer

1 accepted

0 votes
Answer accepted
Ajay Taneja January 20, 2023

I was able to solve this using: 

- 'curl -H Content-Type:multipart/form-data -H "Authorization: Bearer NzEzMDM5MDc0MDU5OhXdEvd5uQFmcTmMLyV6NWuz78Yk" -F file=@coverage2.xml "https://jira.devops.jlr-apps.com/rest/raven/1.0/import/execution/junit?projectKey=VHS&testPlanKey=VHS-1333"'  

 

but now have another problem which I have posted separately but is under moderation!

Pavankumar April 2, 2024

How to upload robot test result.
I'm using 
curl -H "Content-Type: multipart/form-data" -u user:passwd -F "file=@output.xml" https://domain-name.atlassian.net/jira/rest/raven/1.0/import/execution/robot?projectKey=XXXX

but resulting in failure

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Oops, you&#39;ve found a dead link. - JIRA</title><link type='text/css' rel='stylesheet' href='/static-assets/metal-all.css' media='all'><script src='/static-assets/metal-all.js'></script><meta name="decorator" content="none" /></head><body class=" error-page error404"><script type="text/javascript">document.body.className += " js-enabled";</script><div id="page"><header id="header" role="banner"></header><!-- #header --><section id="content" role="main"><div class="aui-page-panel"><div class="aui-page-panel-inner"><section class="aui-page-panel-content lowerContent"><div id="error-state"><span class="error-type"></span><h1>Oops, you&#39;ve found a dead link.</h1><ul><li>Go back to the <a href="javascript&colon;window.history.back()">previous page</a></li><li>Go to the <a href="/secure/MyJiraHome.jspa">Home Page</a></li></ul></div></section><!-- .aui-page-panel-content --></div><!-- .aui-page-panel-inner --></div><!-- .aui-page-panel --></section><!-- #content --><footer id="footer" role="contentinfo"><section class="footer-body">

<ul class="atlassian-footer">
<li>
Atlassian JIRA <a class="seo-link" href="https://www.atlassian.com/software/jira">Project Management Software</a><span id="footer-build-information">(v1001.0.0-SNAPSHOT#100248-<span title='d2a8619c534a6b3769f470bb97e8df1ebd06aed7' data-commit-id='d2a8619c534a6b3769f470bb97e8df1ebd06aed7}'>Rev:d2a8619</span>)</span>
</li>
<li>
<a id="about-link" href="/secure/AboutPage.jspa">About JIRA</a>
</li>
<li>
<a id="footer-report-problem-link" href="/secure/ContactAdministrators!default.jspa">Report a problem</a>
</li>
</ul>
<div id="footer-logo"><a href="http://www.atlassian.com/" rel="nofollow">Atlassian</a></div></section></footer><!-- #footer --></div><!-- #page --></body></html>

Suggest an answer

Log in or Sign up to answer