Spiratest 5.0 REST API record test-run, Example how

Tuesday, August 30, 2016
Avatar
Hi,

I found a few methods in API documentation section:
http://api.inflectra.com/Spira/Services/v5_0/RestService.aspx#Automated%20Test%20Run

In requests body, there are many fields I have no idea how to use. Could someone please explain with some short example how to record an automated test run?
What preconditions needed in testcase/testset?
What are the required and optional fields in request body?


I am using python script to communicate with REST API 5.0 and getting the error:

The server encountered an error processing the request.

I have the following data in POST request body:

postbody = {"ProjectId":  "3", "ExecutionStatusId": "1", "ReleaseId":  "159", "TestCaseId":"15542", "TestSetId":"654", "TesterId":"586", "RunnerName":"Python" }

The exception message is \'There was an error checking start element of object of type Inflectra.SpiraTest.Web.Services.v5_0.DataObjects.RemoteAutomatedTestRun.
Encountered unexpected character \'T\'.\'. See server logs for more details.



2 Replies
Tuesday, September 6, 2016
Avatar
re: andras Tuesday, August 30, 2016
Hi Andras

I think the issue is that you need to stringify the JSON before sending:

http://stackoverflow.com/questions/2484377/wcf-encountered-unexpected-character-c


Regards

Adam
Tuesday, September 13, 2016
Avatar
re: inflectra.david Tuesday, September 6, 2016
Hi,
Thanks Adam for your response.

I think I found out the correct way of calling this method.


Here is my working python code:


    def recordTestRun(self , **kwargs ):
        if kwargs.has_key("projectID"):
            self.projectID = kwargs["projectID"]

        postbody = json.dumps( { "ProjectId":2, "ExecutionStatusId":2, "ReleaseId":157, "TestCaseId":33474, "TestSetId":942, "TesterId":145, "RunnerName":"Python" , "StartDate": "/Date(" + str(int(time.time())) + ")/" , "ConcurrencyDate": "/Date(" + str(int(time.time())) + ")/" } )
        url = self.baseURL +  '/projects/2/test-runs/record'
        result = requests.post( url, headers=self.headers, data = postbody )

        return result

BRs,
Andras

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Tuesday, August 30, 2016
  • Last Reply: Monday, April 4, 2022
  • Replies: 2
  • Views: 18333