Skip to main content
Solved

API and DELETE policy by ID

  • September 29, 2016
  • 1 reply
  • 19 views

Forum|alt.badge.img+12

I'm trying to delete a policy vie the API, however I'm getting "400 bad request" in return. My account has full admin rights and I can GET, PUT, and POST just fine to the same policy. DELETE works for other stuff like Categories and Buildings. I double checked the policy list and I'm trying to delete the right policy ID. Am I missing something simple?

example:
curl -v -uadmin -p https://my.jss.com:8443/JSSResource/policies/id/48 -X DELETE

response:
< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Date: Thu, 29 Sep 2016 02:46:09 GMT
< Connection: close
< Server: Apache

Best answer by Sonic84

nevermind, figured it out. Forgot to quote my URL string....

does not work: curl -v -uadmin -p https://my.jss.com:8443/JSSResource/policies/id/48 -X DELETE

works:
curl -v -uadmin -p "https://my.jss.com:8443/JSSResource/policies/id/48" -X DELETE

also, if you want curl to output the HTTP response code, add this: -w " response code:%{http_code} "
makes error checking a lot easier.

1 reply

Forum|alt.badge.img+12
  • Author
  • Valued Contributor
  • Answer
  • September 29, 2016

nevermind, figured it out. Forgot to quote my URL string....

does not work: curl -v -uadmin -p https://my.jss.com:8443/JSSResource/policies/id/48 -X DELETE

works:
curl -v -uadmin -p "https://my.jss.com:8443/JSSResource/policies/id/48" -X DELETE

also, if you want curl to output the HTTP response code, add this: -w " response code:%{http_code} "
makes error checking a lot easier.