Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add attachment to test execution using XRay REST API

Gaurav Verma May 5, 2015

We are currently evaluating XRay JIRA plugin for Test management. I have got the REST API working by using the documentation here http://confluence.xpand-it.com/display/XRAY/REST+API

As part of our automated test runs screen shots are taken for failed tests.We would like to upload attachments as evidence for test executions. 

How can we upload these attachments for a test execution using REST API?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Diamantino Campos May 5, 2015

Hi Gaurav,

to attach evidences, you have to use the "evidences" field and use base64 for the image.

 

You can see my example below

{
    "info" : {
        "summary" : "Summary of TEst execution",
        "description" : "This execution is automatically created when importing execution results from an external source",
        "user" : "admin",
        "revision" : "1.0.42134",
        "startDate" : "2014-08-30T11:47:35+01:00",
        "finishDate" : "2014-08-30T11:53:00+01:00"
    },
    "tests" : [
        {
            "testKey" : "PPM-1",
            "start" : "2014-08-30T11:51:00+01:00",
            "finish" : "2014-08-30T11:52:30+01:00",
            "comment" : "Execution failed. Example #5 FAIL.",
            "status" : "FAIL",
                        "evidences" : [
                        {
                            "data": "iVBORw0KGgoAAAANSUhEUgAABkIAAAO9CAYAAADezXv6AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEn(rest of base64 image enconding)",
                            "filename": "image21.jpg",
                            "contentType": "image/jpeg"
                        }
                        ],
            "examples" : [
                "PASS",
                "PASS",
                "PASS",
                "PASS",
                "FAIL"
            ],
            "steps": [
                {
                    "status": "PASS",
                    "comment": "Coment on Test Step Result *1*",
                    "evidences" : [
                        {
                            "data": "iVBORw0KGgoAAAANSUhEUgAABkIAAAO9CAYAAADezXv6AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEn(rest of base64 image enconding)","
                            "filename": "image21.jpg",
                            "contentType": "image/jpeg"
                        }
                        ]
                }
            ]
        }
    ]
}

 

Regards

Gaurav Verma May 6, 2015

Thanks Diam, I will try converting images to base64 format.

Diamantino Campos May 20, 2015

Hi, did you manage to solve this issue with my solution?

1 vote
Sudheer_Deloitte February 27, 2018

I tried the above but didn't work for me. Getting HTTP 500 error. Please let me know what exactly to be provided for "data".

José Domingues [Xray]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 28, 2018

Hi,

Could you please open a support ticket providing the your Jira logs and the output returned by the server? This way you'll get a faster answer to this question.

  

Best regards,

Xpand Add-ons Team

Sudheer_Deloitte March 2, 2018

yes opened the support ticket - XRAYSUPPORT-3523 . Please provide suggestions.

Saurabh Gupta July 11, 2019

Facing same problem. I am getting 500 error. Is this solved?

TAGS
AUG Leaders

Atlassian Community Events