Search code examples
jsonapirest-clientadvanced-rest-client

How to pass --data "{'myuid':'testuser1'}" while testing Rest API with the RestClient


I am testing the following API in RestClient but I am not getting the response because I don't know how to pass the --data "{'myuid':'testuser1'}".

curl -k -v -c cookies.txt -b cookies.txt 
     -X POST 
     -H "Content-Type:application/json" -H "Accept: application/json"
     --data "{'myuid':'testuser1'}"
     "https://<isam address>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp"

I have attached the screenshot as well.

How should I correctly pass the --data "{'myuid':'testuser1'}" in the RestClient to get response from the server?

RestAPI Testing


Solution

  • Try this out with little (proper and required) formatting :

    curl -k -v -c cookies.txt -b cookies.txt 
         -X POST
         -H "Content-Type:application/json" 
         -H "Accept: application/json"
         --data '{"myuid":"testuser1"}'
         https://<aa>/mgaapi/sps/apiauthsvc?PolicyId=urn:ibm:security:authentication:asf:mytotp
    

    Format is this: curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL