So with a GET command, setting accept: as part of the header lets the Jamf Pro server know how you’re planning to receive the data. With GET, you’re downloading data from the server and with PUT / POST, you’re uploading to the server. Why? It has to do with which way that data is expected to flow. If you look closely, GET is using different headers than PUT and POST are: The header should look like this for XML input: The header should look like this for JSON output: The header should look like this for XML output: Instead, the Jamf Pro server receives and executes the command to delete the specified data. The reason why DELETE is an exception is that we’re not sending or receiving any XML or JSON data. By specifying XML or JSON using the header, we avoid this issue. Without this header specification, you should get XML but Jamf Pro may send back JSON instead. Command being sent – This will be DELETE, GET, PUT or POST.įor all commands except DELETE, we also need to specify a header as this will specify for Jamf Pro if we’re using XML or JSON.-X or –request – We’re using the curl option for sending a request because we’re sending in a request for Jamf Pro to do something.URL – We’re using the API base URL followed by the specific API endpoint and data identifier.Authentication – In this case, we’re using the username and password of a Jamf Pro user with the correct privileges to run the API command.Tool being used – In this case, we’re using curl.When sending one of these commands to Jamf Pro, you must include the following: When using the Classic API, there are four commands available: In contrast, a number of XML parsing tools (like xmllint and xpath) are installed as part of macOS Catalina and earlier, which means that the Mac admin can currently rely on them being available if the Mac admin needs to run API-using scripts on managed Macs. However, they are not installed as part of macOS Catalina or earlier which means that its up to the Mac admin to make sure the relevant JSON parsing tools are installed and up to date on the Mac admin’s managed Macs. There are tools available for macOS which allow easy JSON parsing and manipulation, with jq being an excellent example. While you can both input and output XML, JSON can only be output. Update – January 3, 2020: As Graham Pugh pointed out in the comments, I made a mistake originally on what can be done with JSON, where I stated that both JSON input and output were supported. There are not tools installed as part of macOS which allow JSON parsing and manipulation when using Bash shell scripting.There are various tools installed as part of macOS which allow XML parsing and manipulation when using Bash shell scripting.Both XML input and output and JSON output are supported:.The Classic API has been around the longest, so more Jamf Pro admins are familiar with it.The reasons that the Classic API is most used at this time are the following: Of the two, the Classic API is the one currently most used by Jamf Pro admins and the one I’ll be focusing on how to use it, using XML for input and output. Creates a new token with the same access rights as the existing token.įor more details, please see below the jump.The new token generation process does the following: However, you can generate a new token for API authentication using the existing token’s credentials. These tokens are time-limited and expire after 30 minutes. The Jamf Pro API is designed to work with token-based authentication, with a Jamf Pro username and password used to initially generate the necessary token. If your Jamf Pro server is, that means that the API base URL is as follows: The base URL for the Jamf Pro API is located at /uapi on your Jamf Pro server. This API is in beta and is designed to be an eventual replacement for the Classic API. The Classic API is designed to work with usernames and passwords for authentication, with the username and password being passed as part of the curl command. To help you become familiar with the API, Jamf includes documentation and “Try it out” functionality at the following URL on your Jamf Pro server: The base URL for the Classic API is located at /JSSResource on your Jamf Pro server. This API is designed to work with XML and JSON. This API is the original one which Jamf Pro started with and it is slated for eventual retirement. Jamf Pro API (formerly known as the Universal API). That means that the curl tool can be used to send commands to and receive information from a Jamf Pro server. Both APIs are REST APIs, which means they can perform requests and receive responses via HTTP protocols like GET, PUT, POST and DELETE. When working with Jamf Pro, one way to save yourself a lot of clicking in the admin console is to use one of the two current Jamf Pro APIs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |