Spiratest 5.0 REST API record test-run, Example how

Tuesday, August 30, 2016 11:42:18 AM

I found a few methods in API documentation section:

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 4:54:26 PM
re: andras on Tuesday, August 30, 2016 11:42:18 AM
Hi Andras

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



Tuesday, September 13, 2016 8:14:39 AM
re: inflectra.adam on Tuesday, September 6, 2016
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

  • Started: Tuesday, August 30, 2016 11:42:18 AM
  • Last Reply: Tuesday, September 13, 2016 8:14:39 AM
  • Replies: 2
  • Views: 2435