I need help writing a Test that verifies an API check

0 Answers 29 Views
API Testing
Brian
Top achievements
Rank 1
Brian asked on 25 Nov 2023, 08:44 PM

I have a Get query that when I run in Postman with the correct security token, returns:

(*** is redacted)

Get https://***/?q=SELECT Id, Portfolio_Status__c, Open_for_Submissions__c FROM Teaching_Portfolio__c WHERE id = '***'

"totalSize"1,
    "done"true,
    "records": [
        {
            "attributes": {
                "type""Teaching_Portfolio__c",
                "url""***"
            },
            "Id""***",
            "Portfolio_Status__c""Invitation Sent",
            "Open_for_Submissions__c""Yes"
        }
    ]

 

I am currently designing a test in Test Studio that will check to see if "Open for Submissions__C" is Yes or No. 

If No, I will run a Patch API Call that changes the value to Yes, and then a Get to verify that the data has been changed. 

If Yes, Test Passed.

Question 1 - I started with an If statement in Test Studio, but the API call I wrote does not appear in the drop down menu as a verification option. Should I instead just have my test run an API Test, and put the If/Then statement in the API test? 

Question 2 - I am having a hard time recreating the API call within Test Studio. For my first step I made an HTTP Request with the above Get call, the security token as Authorization in the body tab, and in the Verification Tab - Source:Body,  is equal to 'Yes'

I do not know what to put in the JSONPath to find that Yes or No value from my API Call. Overall I'm not sure this is the best way to get the information I want. Should I be using a Verification API test instead of HTTP? 

Any help is much appreciated, I'm a bit lost.  

Elena
Telerik team
commented on 27 Nov 2023, 04:08 PM

Hi Brian, 

Please, take the time to review the Demo project in Test Studio for APIs as it demonstrates all of its features and the correct approach of using these. You certainly need to first get the authorization token and then use it to send the GET request.

Next, before you add the verification portion in the HTTP request step, you can run that step once so you can see what body has the response. I guess it will be easier to tailor up the verification then. 

And when it comes to the complete scenario - as far as I understand all needed for this is accomplished through API calls. If this so, then the complete test should be an API test where you can set conditions on the steps where necessary. 

I hope this information will be of further help for you. Thank you for your cooperation in advance. 

Regards,
Elena

No answers yet. Maybe you can help?

Tags
API Testing
Asked by
Brian
Top achievements
Rank 1
Share this question
or