Skip to main content
Solved

Policy Status from Jamf Pro API

  • February 20, 2024
  • 9 replies
  • 222 views

Forum|alt.badge.img+3

I am attempting to get policy statuses for computers from the API. I found a few older posts (from around 2015) saying it wasn't possible, but I also found this post (https://community.jamf.com/t5/jamf-pro/extract-a-jamf-policy-status/m-p/252920) that gave me some hope. I connected with PowerShell and was trying this:

$url = "https://domain.jamfcloud.com/JSSResource/policies/id/318" Invoke-RestMethod -Uri $url -Method Get -Headers @{"Authorization" = "Bearer $token"}

I get a response, but without any information:

xml policy --- ------ version="1.0" encoding="UTF-8" policy

Any ideas on returning policy statuses with the Jamf Pro API? 

Best answer by mm2270

I could likely make it work from pulling the history from a device. Is that available with the Jamf Pro API? I see computerhistory with the Classic API, but I don't see that with the Pro API.


Yeah, unfortunately it's only available right now from the classic API. But is there a reason you can't use that? Both APIs are viable for the time being. Eventually I imagine Jamf will remove the classic API, but probably not until many of the items only available in Classic make their way into the new one.

9 replies

MikePh
Forum|alt.badge.img+4
  • Employee
  • February 21, 2024

What are you looking for when you refer to 'policy status'? Like if it completed or failed? What is the goal you're trying to achieve? 


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • February 21, 2024

To my knowledge, it's only possible to pull history from a device, meaning you can see the policies that have run on an individual computer, but I don't think the API lets you see an entire policy's logs. It would be a nice option to add to the API, but I don't think it currently exists.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • February 21, 2024

What are you looking for when you refer to 'policy status'? Like if it completed or failed? What is the goal you're trying to achieve? 


I would like to see if it completed or failed for the assigned computers. Essentially, just see the policy status that can be viewed in the dashboard. 


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • February 21, 2024

To my knowledge, it's only possible to pull history from a device, meaning you can see the policies that have run on an individual computer, but I don't think the API lets you see an entire policy's logs. It would be a nice option to add to the API, but I don't think it currently exists.


I could likely make it work from pulling the history from a device. Is that available with the Jamf Pro API? I see computerhistory with the Classic API, but I don't see that with the Pro API.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Answer
  • February 21, 2024

I could likely make it work from pulling the history from a device. Is that available with the Jamf Pro API? I see computerhistory with the Classic API, but I don't see that with the Pro API.


Yeah, unfortunately it's only available right now from the classic API. But is there a reason you can't use that? Both APIs are viable for the time being. Eventually I imagine Jamf will remove the classic API, but probably not until many of the items only available in Classic make their way into the new one.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • February 23, 2024

Yeah, unfortunately it's only available right now from the classic API. But is there a reason you can't use that? Both APIs are viable for the time being. Eventually I imagine Jamf will remove the classic API, but probably not until many of the items only available in Classic make their way into the new one.


If I can get the classic API to work, I would have no problem using it. I am able to get a bearer token and use the pro API, but I get access denied each time I try a URL for the classic API. I have the required privileges using an API client and secret.

From what I can find, it seems the method of acquiring a token is the same for the classic and pro APIs, so I'm really not sure where the issue is. 


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • February 23, 2024

Yeah, unfortunately it's only available right now from the classic API. But is there a reason you can't use that? Both APIs are viable for the time being. Eventually I imagine Jamf will remove the classic API, but probably not until many of the items only available in Classic make their way into the new one.


Please disregard my previous response, I had a typo in my URL. I am getting a reponse using the following URL: 'https://domain.jamfcloud.com/JSSResource/computerhistory/id/id' but the response doesn't have any actual information it just returns: 

xml computer_history --- ---------------- version="1.0" encoding="UTF-8" computer_history

Forum|alt.badge.img+3
  • Author
  • New Contributor
  • February 23, 2024

Yeah, unfortunately it's only available right now from the classic API. But is there a reason you can't use that? Both APIs are viable for the time being. Eventually I imagine Jamf will remove the classic API, but probably not until many of the items only available in Classic make their way into the new one.


I got it working with changing around the output format. Thank you for the assistance.


MLBZ521
Forum|alt.badge.img+11
  • Valued Contributor
  • March 7, 2024

Please disregard my previous response, I had a typo in my URL. I am getting a reponse using the following URL: 'https://domain.jamfcloud.com/JSSResource/computerhistory/id/id' but the response doesn't have any actual information it just returns: 

xml computer_history --- ---------------- version="1.0" encoding="UTF-8" computer_history

This looks like you're using PowerShell.  The response comes back as an object and you would have to "dive" down into that nested object.  It will not simply "echo" the entire object to shell.