Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort or order a JSON response received from XRAY REST API

Tushar Daharwal November 3, 2020

I am using below end point for getting the test runs of test case in Xray , however the JSON response I get multiple test runs the test cases is linked to.

Is there a way to add a sort/order parameter to an API url query string so that latest test run should come at the top of list.

GET /rest/raven/2.0/api/test/{testKey}/testruns

Sample response :

{
        "id": 7,
        "status": "PASS",
        "testKey": "test-2345",
        "testExecKey": "test-1234",
        "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/follettkyle/128.jpg"
    },
    {
        "id": 2,
        "status": "TODO",
        "testKey": "test-2345",
        "testExecKey": "test-8956",
        "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/araa3185/128.jpg"
    }
]}

 

1 answer

1 accepted

0 votes
Answer accepted
Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2020

Hi @Tushar Daharwal 

Xray has no such feature and all endpoint options available are detailed on our REST API documentation, so when available it will be listed there.
Any other response has to be handled on the user's side, you have to adjust and create such ordering.

For more information on our REST, please review the link REST API.

Best Regards, 

 

Sérgio Freire,

Solution Architect and Testing Advocate @Xray

Personal blog on testing, Agile, and software development: https://sergiofreire.com

Follow me on Twitter: https://twitter.com/darktelecom

Tushar Daharwal November 10, 2020

Thanks @Sergio Freire - Xblend . Also could you please help me with below query ?

 I have been trying to send the evidence of test runs to Xray using below PUT method, but unable to attach files to test execution

PUT:  https://jira.****.net/rest/raven/2.0/api/testrun/****

Note: Test Run Status is getting updated but the file is not getting attached. Can "filename" accept file path ?

JSON Body:

{    

"status""PASS",    

"comment":"{TD Test Comment}",    

"evidence":{       

 "add:[{            

"filename":"C:\\Users\\tda090\\Desktop\\provar.pdf",            

"contentType""application/pdf",            

"data""(base64 encoding...)"        }
        ]    }

}

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2020

@Tushar Daharwal , filename should be just the file's name, without path whatsoever.

Regards

Sérgio

Tushar Daharwal November 10, 2020

Thanks @Sergio Freire - Xblend

Is there a way to pass the file path as I need to pull the file from specific folder in project. Tried storing the path with filename into variable and passing the variable as a string in "filename" but its not helping.

Sergio Freire - Xblend
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2020

Perhaps as a comment or as a Test Run custom field...?

Please have a look at:

https://docs.getxray.app/display/XRAY/v2.0#/Test%20Run/put_testrun__id_ 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events