Issue
Via Postman the Api which i am using is:-
href="https://myCertManager.com/api/pik/restapi/MyCerts?INPUT_DATA=%7B%22operation%22:%7B%22details%22%7B%22Cert_Name%22:%22cert1%22%7D%7D%7D" rel="nofollow noreferrer">https://myCertManager.com/api/pik/restapi/MyCerts?INPUT_DATA={"operation":{"details"{"Cert_Name":"cert1"}}}
with authtoken in header "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX"
When I send the get request via postman I get my certificate in the response body which is correct
Now I need to fetch this cert via curl command, so I created these two commands but when I execute them they connect to the server but the body of the response is coming empty.
curl -g -k -v -X GET https://myCertManager.com/api/pik/restapt/MyCerts?INPUT_DATA={"operation":{"details"{"Cert_Name":"cert1"}}} -H "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX"
curl -k -v -X GET https://myCertManager.com/api/pik/restapt/MyCerts -H "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX" -d "INPUT_DATA={"operation":{"details"{"Cert_Name":"cert1"}}}"
Solution
The issue was because the GET
parameter doesn't support -d
parameter. So this type of code will never work.
curl -k -v -X GET https://myCertManager.com/api/pik/restapt/MyCerts -H "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX" -d "INPUT_DATA={"operation":{"details"{"Cert_Name":"cert1"}}}"
Secondly the GET
parameter only sends the data through the url itself so the INPUT_DATA
needs to be in the URL itself like this one
curl -g -k -v -X GET https://myCertManager.com/api/pik/restapt/MyCerts?INPUT_DATA={"operation":{"details"{"Cert_Name":"cert1"}}} -H "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX"
But the URL dosent support the braces and quotes {} ""
and to what i did was converted the INPUT_DATA
to the URL
format. So the actual working code is this one.
curl -g -k -v -X GET https://myCertManager.com/api/pik/restapt/MyCerts?INPUT_DATA=%7B%22operation%22%3A%7B%22details%22%7B%22Cert_Name%22%3A%22cert1%22%7D%7D%7D -H "AUTHTOKEN: XXXX-XXXX-XXXX-XXXX"
Answered By - Ashwani Singh Answer Checked By - Willingham (WPSolving Volunteer)