jenkinscurlpostmanjenkins-api

Jenkins Remove Item via curl with api


I am somewhat new to using API's. In the below question, the answer mentions using the http://<MY_SERVER>/job/<MY_JOB>/api url's instructions for deleting a job. This involved sending a POST request to http://<MY_SERVER>/job/<MY_JOB>/doDelete. When I navigate to my Jenkins job's api url, it advises me to send an HTTP DELETE to http://<MY_SERVER>/job/<MY_JOB>. Using Postman, this doesn't work. The old method using doDelete however does work.

Can anyone explain this behavior? For now I'll be using the old method.

The version of Jenkins I'm using is CloudBees Jenkins Enterprise 2.249.2.4-rolling.

Jenkins remove project via API via curl


Solution

  • just right click and choose copy link address , you can see that there is an ending "/"

    so if you want to delete a job named Zap_Scan, use:

     DELETE https://jenkins.io/job/Zap_Scan/
    

    don't use

     DELETE https://jenkins.io/job/Zap_Scan
    

    that's don't remove the last forward slash.

    Note: the success response code will be 204