How do I access a POST service - REST
|
|
This example demonstrates getting the execution status of a test run by accessing a GET service - REST.
In the solution shown below, the GET method is used to retrieve information from the given server using a given URI. The requests using GET only retrieve data and has no other effect on the data.
Solution:
| # | Command | Target | Value |
|---|---|---|---|
| Start of a web service block |
|||
| 1 | wsBlockOpen | ||
| To set the Header Protocol |
|||
| 2 | wsSetProtocol |
REST | |
| To set the request URL for getting the results of the test run |
|||
| 3 | wsSetRequestURL |
https://www.eureqatest.com/rest/v1/ ${test_cycle_QaCONNECT_domain}/executions |
URL |
| To set the type of request method to hit the appropriate service |
|||
| 4 | wsSetRequestMethod |
POST |
|
| To set the authentication type - Basic |
|||
| 5 | wsAuthenticationType | Basic | |
| To set the Username to login to Worksoft SaaS Domain |
|||
| 6 | wsSetUsername |
your user name |
|
| To Set the Password to login to Worksoft SaaS Domain |
|||
| 7 | wsSetPassword | your password |
|
| To set the request body format and output type |
|||
| 8 | wsSetRequestHeaderParam | Content-Type |
application/json |
| Set the payload required for accessing the service |
|||
| 9 | wsSetRequestPayload | { "TestCycleIdentifier": "Your Test Cycle Identifier", "RunDefinitionTestingContextKeys": [ { "id":"YOUR_RUN_DEF_TESTING_CONTEXT_KEY", "status":"YOUR_RUN_DEF_STATUS", "userNotes":"SOME_DESCRIPTION" } ] } |
|
| Execute the Service Request |
|||
| 10 | wsExecuteRequest |
${URL} |
Response |
| To get the response code |
|||
| 11 | wsGetResponseHttpStatusCode |
Status_Code |
|
| End of a web service Block |
|||
| 12 | wsBlockEnd |
||
Tips, Tricks, Gotchas & Best Practices:
- You can also Remotely trigger executions of automated tests in Worksoft SaaS and expect a Callback from Worksoft SaaS when execution completes/aborts using POST method.
- You can prepare all the test runs of a test cycle (or a subset thereof) for execution. This step is also called 'preprocessing' the test runs using POST method.
|
|
|