Posted on 06-28-2023 05:15 PM
Hi Folks,
I am unable to get a log flush via API to work. Ideally going by the Classic API and Jamf recipe it should be something like this:
curl --request DELETE \
--url https://yourserver.jamfcloud.com/JSSResource/logflush/policy/interval/0
but I get an error!
<html>
<head>
<title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Unauthorized</p>
<p>The request requires user authentication</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>
Here is my complete script
jamfUrl="https://jss.url.com:8443"
# Login Credentials
username="username"
password='mypassword'
# Bearer Token Function. Get jamf's API token, extract the token and the expiry date
getBearerToken() {
response=$(curl -s -u "$username":"$password" "$jamfUrl"/api/v1/auth/token -X POST)
bearerToken=$(echo "$response" | plutil -extract token raw -)
}
# Run the Bearer Token Function
getBearerToken
curl --request DELETE \
--url "$jamfUrl"/JSSResource/logflush/policy/interval/0 \
--header 'accept: application/xml' \
--header "Authorization: Bearer $bearerToken"
Any ideas?