This is the response body in JSON format. We’re really interested in the very last line of the console (highlighted above). You should get something like this in the Console: With the Console open, go ahead and send your request to your Jamf Pro server. Open the console in Postman by clicking on “Console” in the status bar of the window: We’ll start with grabbing the entire response body and outputting it to the console so we can see what we’re getting. First we need to convert the output from XML to JSON, since JSON is much easier to work with here. Textexpander 4 serial number serial numbers#To capture the serial numbers we will use the Test tab to place the response body from our request into an array variable. Once we have the serial number, we will need to store that in an array that can be used by the next request in our chain of requests: “Update Computer By SN”. Textexpander 4 serial number serial number#To get to the serial number of our computers, we have to traverse into the section, then into the section, then into each object, and finally pull the key. Wow, that’s a lot of data, and you can see (based on the tab indents) that we have a few nests to work out. In our demo case the XML from our search for devices that have a model identifier like “macmini” results in: With the ID number in hand, we can use the “Find Computer Search by ID” API endpoint ( /JSSResource/advancedcomputersearches/id/:id) to pull back the XML of that search. To do this we will need the ID number of our Advanced Search (ID can be found in the URL of your advanced search, like: id=6). Investigate the Dataīefore we get too far down the rabbit trail, we will need to understand where the serial numbers are in the response body of an Advanced Search, and how far they are nested. This could be testing the response code that is returned to make sure the request ran, or it can be storing your results for use in the next request in a Runner (which is what we will be doing). Similar to the Pre-Request Scritps tab, the Tests tab allows you to utlize JavaScript to perform actions after the request has run. We did it this way so that we did not change the Params tab of the request and hardcode the ID variable so we can use the request in a runner later. set to set the “id” variable to the ID of a policy. In that instance we used the command pm.environment. We used a pre-request script in Part 2 when we briefly talked about using variables. A Pre-Request Script can allow us to set variables before the running of a request. Postman provides two features that allow us to utilize JavaScript to manipulate data, either before or after a request: Pre-Request Scripts and Tests. To do this we will need an Advanced Search in Jamf Pro to capture our devices and in Postman we will use two API endpoints: “Find computer search by ID” and “Update computer by SN”. Textexpander 4 serial number update#Our use case, for this post, is to update the PO Number on a group of computers that we will gather using an Advanced Search in Jamf Pro. Sure, we can run a search, export the data as a CSV, and then use that CSV to feed a runner, but what if we could grab a search in Postman and parse out the devices we want to update? I went down this rabbit trail today and wanted to share the results with you. Maybe we want update a list of devices with PO Number or some other data. Often times we want to perform an action on more than just one object. In this post I’m going to expand a little on our use of the Runner functionality which I covered in Part 4 and Part 5. Textexpander 4 serial number how to#In my previous posts about Postman I showed you how to setup Postman for working with Jamf Pro, how to create and update policies, how to gather our queries into collections, and much more.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |