0

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

Valentin Despa
  • 40,712
  • 18
  • 80
  • 106
  • little bit proper googling would yield you desired result. https://stackoverflow.com/questions/13132794/firefox-add-on-restclient-how-to-input-post-parameters – mfaisalhyder Oct 23 '17 at 09:44
  • I have set the **Content-Type** and **value** = **application/json** in request header. Is there any special format for passing the --data "{'myuid':'testuser1'}" in the request body for Content-Type=application/json? – Abdullah Khan Oct 23 '17 at 09:59
  • https://my.usgs.gov/confluence/display/sciencebase/Using+RESTClient+for+Firefox check this and see where are you doing wrong. one more thing shouldn't the key values be in double quotes rather than single? – mfaisalhyder Oct 23 '17 at 10:05
  • I answered it try and tell if it worked or not – mfaisalhyder Oct 23 '17 at 10:11
  • Yes I have now tried with **{"myuid":"testuser1"}** in request body and successfully received the response. – Abdullah Khan Oct 23 '17 at 10:34
  • then accept the answer, please. here people ask question and get answers whichever answer solves their problem they accept as a solution. – mfaisalhyder Oct 23 '17 at 11:52

1 Answers1

0

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

mfaisalhyder
  • 2,250
  • 3
  • 28
  • 38