JSS API PUT returns HTTP 409 conflicting names sometimes

MartyWhite
New Contributor

I am attempting to use the JSS API to programatically manipulate the list of packages in various policies, but when I "PUT /policies/id/123" (using an appropriate policy number) I am getting unpredictable "HTTP 409 CONFLICT" errors, where the returned HTML says that there are "conflicting names". The JSS in question has various sets of identically-named policies, usually with different sites/categories/buildings, and there is no problem with creating as many identical copies of a policy using the human/web interface as I want (even with the same site, category, and building). But sometimes I can't PUT changed/updated XML for a policy, and sometimes I can just fine, seemingly randomly.

Questions:

  • Does the "conflicting names" refer to policy names, or might it refer somehow to other conflicting names of things inside the policy?

  • Should I in fact be able to PUT (& POST) policies distinguished by different IDs but with identical names?

  • When PUTting an update, should I pass in the entire/complete (updated) XML for the policy, or just those parts of the XML tree that I want to change? I don't know what is normal for RESTful PUT updates, if there is a norm.

  • Has anyone ever done anything like this? What problems did you have, if any?

  • Ideas?

1 ACCEPTED SOLUTION

BrysonTyrrell
Contributor II

Hi @MartyWhite ,

I passed this post along to Support. You're seeing conflicting behavior between the GUI and the API which I recreated in my own instance.

Should I in fact be able to PUT (& POST) policies distinguished by different IDs but with identical names?

The GUI is allowing you to create multiple policies with identical names, but the API is restricting this claiming the "name" is supposed to be a unique value. Your PUT requests are going to fail if you're trying to manipulate a policy that shares an identical name with another. I've been able to recreate all of this behavior.

When PUTting an update, should I pass in the entire/complete (updated) XML for the policy, or just those parts of the XML tree that I want to change?

The JSS API treats PUT like its PATCH according to the standards. You don't have to pass the entire object with your request; only the parts you want to change.

View solution in original post

2 REPLIES 2

BrysonTyrrell
Contributor II

Hi @MartyWhite ,

I passed this post along to Support. You're seeing conflicting behavior between the GUI and the API which I recreated in my own instance.

Should I in fact be able to PUT (& POST) policies distinguished by different IDs but with identical names?

The GUI is allowing you to create multiple policies with identical names, but the API is restricting this claiming the "name" is supposed to be a unique value. Your PUT requests are going to fail if you're trying to manipulate a policy that shares an identical name with another. I've been able to recreate all of this behavior.

When PUTting an update, should I pass in the entire/complete (updated) XML for the policy, or just those parts of the XML tree that I want to change?

The JSS API treats PUT like its PATCH according to the standards. You don't have to pass the entire object with your request; only the parts you want to change.

MartyWhite
New Contributor

Thank you very much! I had not previously heard of HTTP PATCH, but I get it. So I will proceed with the assumption that for now I can't allow/depend on working with identically named policies.