Hello,
So, I have been trying to obtain a specific data from UAPI, but keep getting 404 errors, which is a response code that it cannot find the data requested... I am able to generate and authenticate with the token fine and I am even able to pull lists, for example pulling the list of all computers via:
computerslistall=$(curl -X GET --header "Authorization: Bearer $token" "Accept: application/json" "$jssurl/uapi/preview/computers")
Is working fine and if I echo $computerslistall - I get a full list of all computers currently in JSS. However, when I am trying to obtain a specific computer, no matter what I try I get 404... I have tried:
$jssurl/uapi/preview/computers/id/XXXX
$jssurl/uapi/preview/computers/ComputerOverview/id/XXXX
$jssurl/uapi/preview/computers/results/id/XXXX
So far I have been unable to find any GET example where a specific data is obtained via UAPI. Would appreciate if anybody has any info/explanation/example on this.
Here is a full script code, if anybody needs a working token creation/user via UAPI - this should work for you:
# server connection information
jssurl="https://jss.XXXXXX.com:8443"
username="XXXXXX"
password="XXXXXXXX"
# created base64-encoded credentials
encodedCredentials=$( printf "$username:$password" | /usr/bin/iconv -t ISO-8859-1 | /usr/bin/base64 -i - )
# generate an auth token
authToken=$( /usr/bin/curl "$jssurl/uapi/auth/tokens"
--silent
--request POST
--header "Authorization: Basic $encodedCredentials" )
# parse authToken for token, omit expiration
token=$( /usr/bin/awk -F " '{ print $4 }' <<< "$authToken" | /usr/bin/xargs )
# get existing json for PreStage ID | TESTING TOKEN / DATA retreival via UAPI
#prestageJson=$( /usr/bin/curl "$jssurl/uapi/v1/computer-prestages/$prestageID/scope" --silent --request GET --header "Authorization: Bearer $token" )
#echo "prestageJson is: $prestageJson"
#Start the UAPI scripts#
computerslistall=$(curl -X GET --header "Authorization: Bearer $token" "Accept: application/json" "$jssurl/uapi/preview/computers")
echo "computerslistall is: $computerslistall"
#End the UAPI scripts#
# expire the auth token
/usr/bin/curl "$jssurl/uapi/auth/invalidateToken"
--silent
--request POST
--header "Authorization: Bearer $token"
exit 0
It is also very hard to find anything on UAPI, as it keeps finding old API stuff lol