It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Submitting XRay Test Execution Evidence via Rest API in Version 3 Edited

Mohamed Ibrahim Aug 17, 2018

It seems that the XRay Rest API Documetation has not been updated to reflect all changes in Version 3.

According to the documentation at "https://confluence.xpand-addons.com/display/XRAY/Test+Step+Results+-+REST" evidences should be sent in the following format:

      {
         "filename":"test.txt",
         "contentType":"plain/text",
         "data":"(BASE64 encoding)"
      }

However, it seems that this is not valid anymore. The documentation does not reflect the changes. Obviously the EvidenceBean has been substituted by the AttachementBean which accepts "filename" and "mimeType" properties but does not have any data fields. I can't figure out how to change the request for it to work.

And as I don't have admin access to our company's Jira I can't send a support request and I don't really want to go through the official channels for this.

Does anyone have an idea how the rest calls should be adjusted? I can't find anything on the internet.

1 answer

0 votes
José Domingues Aug 21, 2018

Hi Mohamed Ibrahim,

Thanks for your question; the documentation seems to be correct though.

 

If you do a POST request to an URL such as:

http://jiraserver/rest/raven/1.0/api/testrun/4151/step/3200/attachment 

 

And you pass the body json content such as:

{
"data":"iVBORw0KGgoAAAANSUhEUgAABkIAAAO9CAYAAADezXv6AAAAAXNSR0IArs4c6QAA",
"filename":"image21.jpg",
"contentType":"image/jpeg"
}

it works fine.

 

What Xray version are you using? This was evaluated in the latest one.

 

Best regards,

Xray Team

Mohamed Ibrahim Aug 22, 2018

Unfortunately I do not know the exact version of the XRay installation because I do not have admin access to Jira. However I know that it is 3.x. If you need the exact version I can try to ask our admins if I can find them.

Posting the evidence the way you suggested does work, so I will try to use it instead of my original approach.

However, when trying to send following PUT Request to add the evidence while creating a test step execution I do get the error, and according to the documentation it should be fine:

jiraserver/rest/raven/1.0/api/testrun/42578/step/334560

{
   "status":"PASS",
   "comment":"Everything worked as expected :)",
   "evidences":[{
       "data":"SGVsbG8=",
       "filename":"testfile.txt",
        "contentType":"plain/text"
   }]
}

 

I then get some error message, here the first part of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>500</status-code><message>Unrecognized field &quot;data&quot; (Class com.xpandit.raven.beans.AttachmentBean), not marked as ignorable
 at [Source: org.apache.catalina.connector.CoyoteInputStream@1a57974; line: 6, column: 13] (through reference chain: com.xpandit.raven.beans.TestStepResultBean[&quot;evidences&quot;]-&gt;com.xpandit.raven.beans.AttachmentBean[&quot;data&quot;])</message><stack-trace>org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field &quot;data&quot; (Class com.xpandit.raven.beans.AttachmentBean), not marked as ignorable
 at [Source: org.apache.catalina.connector.CoyoteInputStream@1a57974; line: 6, column: 13] (through reference chain: com.xpandit.raven.beans.TestStepResultBean[&quot;evidences&quot;]-

José Domingues Aug 24, 2018

Hi Mohamed Ibrahim,

Unfortunately that's a bug.

We're on it. You may track it here: https://jira.xpand-addons.com/browse/XRAY-3106

 

Best regards,

Xray Team

Alessandra Dias Nov 27, 2018

Hi José Domingues ,

how can I find the stepResultId

for use http://jiraserver/rest/raven/1.0/api/testrun/id/step/stepResultId/attachment ,

 

Thanks

Like Nishi Agarwal likes this
Nishi Agarwal I'm New Here Apr 30, 2019

Can you help me in the same to find the TestRun id and the Step Result Id for posting the evidence and Creating a issue in Xray for the TestExecution

José Domingues May 30, 2019

Hi Nishi,

This endpoint should provide the necessary information:
GET /rest/raven/1.0/api/testrun/

More details here:
https://confluence.xpand-it.com/display/public/XRAY/Test+Runs+-+REST

 

Best regards,

Xray Team

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

64 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you