API Question

rstasel
Valued Contributor

Hi All,

I'm trying to use the JSS API, and I can't seem to find documentation on how or if it works if your JSS is broken into sites, and you only have read/write to a specific site.

Our campus has a central Casper server, and I only have access to my specific site... but I'm not sure if the API is smart enough to actually drop my posted data into my site, or if the reason I'm getting "Conflict" (Error 409's) back is because it's saying I don't have rights to create content in the root of the JSS.

Here's what I'm trying:

curl -skfu username:password https://casper.example.com:8443/JSSResource/computergroups/id/0 -T ~/Desktop/macOSSierraIncompatible.xml -X POST;

content of that xml is from here: https://derflounder.wordpress.com/2016/09/20/building-a-casper-smart-group-containing-sierra-incompatible-macs/#more-8325

Help?

10 REPLIES 10

thoule
Valued Contributor II

Do you have permission to create a smart group? Can you do it in the GUI? That process should work. I have had issues in the past where if my 'site' is not set in the JSS to the one I have write access to, the API call will fail. Perhaps open the web browser, make sure your site is set properly, test creating a smart group, then try the API run again...

Emmert
Valued Contributor

Thanks for the link! That worked for me out of the box, but we're not using sites. I think your suspicion is correct.

rstasel
Valued Contributor

I do have permissions to create smart groups within my site, not within the full JSS.

rstasel
Valued Contributor

Any other ideas on this, or options for more troubleshooting?

talkingmoose
Moderator
Moderator

I personally haven't tried creating a smart computer group within a site when I only have access to the site. See if adding the site after the the is_smart element helps.

<?xml version="1.0" encoding="UTF-8"?>
<computer_group>
  <name>Macs incompatible with macOS Sierra</name>
  <is_smart>true</is_smart>
  <site>
     <name>Site Name</name>
  </site>
  <criteria>
    <size>37</size>
...

rstasel
Valued Contributor

!!!

That worked!!!

Thank you! Totally need to document this somewhere. =)

talkingmoose
Moderator
Moderator

Glad that helped.

You'd see the site element in the XML if you were logged in to the full JSS or a member of a group with access to more than just one site. For other JSS objects you need to create, remember it'll appear in about the same location (just below the type of element you're creating).

talkingmoose
Moderator
Moderator

Glad that helped.

You'd see the site element in the XML if you were logged in to the full JSS or a member of a group with access to more than just one site. For other JSS objects you need to create, just remember it'll appear in about the same location (just below the type of element you're creating).

JKoopman
New Contributor III

By the way, this smart group has 37 criteria and caused us some problems months down the road. Apparently it's not a good idea to make smart groups that are so difficult to calculate...

JKoopman
New Contributor III

By the way, this smart group has 37 criteria and caused us some problems months down the road. Apparently it's not a good idea to make smart groups that are so difficult to calculate...