Skip to content

REST API call

gcvfi edited this page Feb 20, 2020 · 7 revisions

Back to AIQ Commands | Home


Note: Draft content, work in progress, not yet reviewed or verified.


Syntax

GET API Call

save _api{CURL("GET", end_point_url)} as var_response_body

POST API Call

save _api{CURL("POST", end_point_url, request_body)} as var_response_body

POST API Call with header

save _api{CURL("POST", request_header, request_body, end_point_url)} as var_response_body

PUT API Call

save _api{CURL("PUT", end_point_url, request_body)} as var_response_body

Sample API Call Test Cases

Sample 1 - POST Call

Test Step Test Data
open website https://www.google.com/
save _api{CURL("POST", "https://reqbin.com/echo/post/json", "{'login':'login','password':'password'}")} as post_response
Enter Search ${post_response}
save _api{GET(CURL("POST", "https://reqbin.com/echo/post/json", "{'login':'login','password':'password'}"), "success")} as post_response_success
Enter Search ${post_response_success}
wait for 1 secs
... ...
... ...

Sample 2 - POST Call with variables

jsonplaceholder_url = https://jsonplaceholder.typicode.com/posts
jsonplaceholder_body = {"userId": 1, "title": "foo", "body": "bar"}
Test Step Test Data
open website https://www.google.com/
save _api{CURL("POST", ${jsonplaceholder_url}, ${jsonplaceholder_body})} as jsonplaceholder_response
Enter Search ${jsonplaceholder_response}
wait for 1 secs
... ...
... ...

Sample 3 - POST Call with headers

  • Please note the change in position of URL parameter.
jsonplaceholder_url = https://jsonplaceholder.typicode.com/posts
jsonplaceholder_body = {"userId": 1, "title": "foo", "body": "bar"}
jsonplaceholder_headers = { "Content-type": "application/json; charset=UTF-8" }
Test Step Test Data
open website https://www.google.com/
save _api{CURL("POST", ${jsonplaceholder_headers}, ${jsonplaceholder_body}, ${jsonplaceholder_url} )} as jsonplaceholder_response
Enter Search ${jsonplaceholder_response}
wait for 1 secs
... ...
... ...

See also

Clone this wiki locally