It's all about the answers!

Ask a question

How can I delete a service provider link, or the entire collection, using the REST API with curl?

Ryan McBryde (511923) | asked Sep 08, 9:12 a.m.

 I have a curl script that will step through my list of active RDNG projects and will present me with a list of the Associations that each project has with other projects, such as RTC for Change Requests, or RQM for Test Cases. I am using REST API calls found here:  The API call that I use to present the list looks like this:  curl -k -b cookies.txt -H "Accept: application/xml" "https://<host>:9443/rm/process/project-areas/_01KIgzQjEeazXZOTb1V8ow/links"

What I want to do is to remove one the Association links or in some cases remove all the links for the project.  I am struggling with the syntax to do the delete.  This is what I have tried to delete a single link:
curl -D - -k -b  cookies.txt -X DELETE "https://<host>:9443/rm/process/project-areas/_01KIgzQjEeazXZOTb1V8ow/links/_5ui5UTQjEeazXZOTb1V8ow"
When I do I get a nasty looking java error that concludes with the message: "You don't have permission to perform the following actions:   Modify project area properties (modify/other)"
I have also tried deleting the collection itself instead of the individual links using this command:
curl -D - -k -b  cookies.txt -X DELETE "https://<host>:9443/rm/process/project-areas/_01KIgzQjEeazXZOTb1V8ow/links"
That returns a "400 Bad Request" and the message, "Missing parameter "type"
I can see in the output from the listing curl command that each of the links shows a <jp:link-type> with "validated-by" or "implemented-by" or "tracked-by-cm"  but I can't seem to find the syntax to specify the type on the curl command itself.
This is in CLM 6.0.1 and we are archiving one of the CLM applications, such as RQM, and as part of the decommissioning process, I would like to do a bulk removal of all the Associations in each RDNG project and this seems to be a better way to do it than to open up each RDNG project and manually remove the association links.  I assume that I am close but just can't figure out the correct syntax.
Thank you

Accepted answer

permanent link
Ryan McBryde (511923) | answered Sep 28, 12:08 p.m.


Thanks for the suggestion.  After some trial and error, this appears to work:

curl -D - -k -b .\cookies.txt -X DELETE -G https://<QM_SERVER>:9443/qm/process/project-areas/_6Db1UgLLEeSbwp7ZNy4XUQ/links -d type=tracked-by -d resource="https://<CCM_SERVER>:9443/ccm/process/project-areas/_2cXoAgLLEeSfK8RNZdnwOg"

Not sure what the -G option to curl does but this syntax works to successfully delete an association link between a QM project and and CCM project.  I can use it in my code to loop through all existing associations and remove them.

Ralph Schoon selected this answer as the correct answer

Ralph Schoon commented Sep 29, 4:33 a.m. | edited Sep 29, 5:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER explains that -G causes cURL to perform a GET command. I can not make sense of the command. It does not import into RESTClient. For all I know it does not make sense to debug using cURL eiother. Use RESTClient or Postman or any other client for experimentation and then create the cURL from it.

Ryan McBryde commented Oct 03, 9:25 a.m.


Thanks for the information on the -G option. As I said, the perl script works and removes all the associations cleanly in every project EXCEPT those where my id is not listed as an Admin.  I had seen this problem in a similar user removal script and had addressed it by adding my id to the "admins" list for those projects, by including a "X-Jazz-CSRF-Prevent" with the JSESSIONID and passing my userid info as an xml string to a POST command.  This logic works fine in my stage environment but in my prod env it throws a "Cannot save the Project Area" error even though the id that I am running the script with is a member of the JazzAdmins group and I can easily go in and add my userid to the Admins list using the GUI.  I am using -ssl as an argument and I think my servers all use TLSv1.2.  Would that make a difference?  Any thought s would be appreciated.  Thanks

One other answer

permanent link
Ralph Schoon (59.0k23642) | answered Sep 14, 9:13 a.m.
The documentation specified that the delete request requires two parameters.

The error indicates that a parameter is missing and the cURL code does not show that parameter either.

I would suggest to use RESTCLIENT in Firefox to play around with the API to find out how the request would look like and generate the cURL code once that works.

Ryan McBryde commented Sep 28, 11:35 a.m.

Thank you very much Ralph.  I will see if I can figure the syntax out using that method.  Any idea how you might pass a parameter to the curl cmd?  Is something like the curl command followed by

Your answer

Register or to post your answer.