Skip to main content

Hello!



Maybe someone has any idea? I try to get numbers from the JSS by using the API.
I try to run this command:



var=$(curl -L -skfu jssuser:jsspassword ‘https://JSS_URL/JSSResource/computergroups/id/1' | /usr/bin/awk -F ‘<size>|</size>’ ‘{print $4}‘)


When I run this command with the URL of my test-jss it works like expected.
But when I run it with the URL of my productive JSS it gets no value at all. I have no idea why.. the user and password are correct, if I try them on https://JSS_URL/api at “computergroups” it works, so should be no problem… any idea? Would be glad about any help…

Not 100% sure, but my guess is your production JSS is sending back JSON instead of xml. You may need to add a header to the curl command to tell it to send back xml, which is what the script expects.



curl -H "Accept: text/xml" -sfku jssuser:jsspassword ..... (rest of command)


As an aside, I've never needed to use the -L flag with curl against the API. That tells curl to follow links that it encounters which doesn't apply with the API as far as I know.


Thank you mm2270!!! You really made my day 🙂



Now it works!