{"id":891,"date":"2020-11-10T10:23:20","date_gmt":"2020-11-10T15:23:20","guid":{"rendered":"https:\/\/www.brunerd.com\/blog\/?p=891"},"modified":"2020-11-10T10:23:22","modified_gmt":"2020-11-10T15:23:22","slug":"jpt-jamf-uapi-backupjamf-scripts","status":"publish","type":"post","link":"https:\/\/www.brunerd.com\/blog\/2020\/11\/10\/jpt-jamf-uapi-backupjamf-scripts\/","title":{"rendered":"jpt + jamf uapi = backupJamf-scripts"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Jamf UAPI: JSON Only<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">I am a creature of habit, no doubt, however sometimes you must get out of your comfort zone. The Jamf Universal API (UAPI) is one such case, it is JSON only and not XM. Those tried and true xpath snippets will no longer work with JSON, in fact what tool do you use with JSON? macOS really doesn&#8217;t have a good built-in JSON tool and if your scripts are client side do you really want to have jq as a dependency? Good thing I wrote a JSON parser you can embed in your scripts this summer! In fact, when I finished writing my JSON power tool <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/jpt\" target=\"_blank\">jpt<\/a>, I needed to find some practical examples to demonstrate its utility. Looking at the UAPI it&#8217;s clear some parts are still a work-in-progress, however the endpoint for <strong>scripts<\/strong> is actually really good. It gives you <strong>everything<\/strong> in one go almost like a database query. That should made backing up scripts a breeze!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">backupJamf-scripts. boom.<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;ve used the Classic API from Jamf, it is a 1:1 ratio of scripts to API calls: 2 scripts? 2 API calls via curl. 200 scripts? 200 API calls via curl. The new Universal API reduces that down to 1 call to get everything (plus one call to get the token), it&#8217;s super fast and I love it. Check out <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/jamfTools\/tree\/main\/backup\/backupJamf-scripts\" target=\"_blank\">backupJamf-scripts.command<\/a> in my newly minted <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/brunerd\/jamfTools\" target=\"_blank\">jamfTools<\/a> repo on GitHub for a working demostration of both the Jamf UAPI and jpt&#8217;s in-script JSON handling. I hope you like it!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"449\" src=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/backupJamf-scripts.png\" alt=\"\" class=\"wp-image-895\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/backupJamf-scripts.png 473w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/backupJamf-scripts-300x285.png 300w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><figcaption>jpt + jamf uapi = scripts downloading scripts<\/figcaption><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"backupJamf-scripts Demo\" width=\"648\" height=\"486\" src=\"https:\/\/www.youtube.com\/embed\/cMVTKsV82L4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Jamf UAPI: JSON Only I am a creature of habit, no doubt, however sometimes you must get out of your comfort zone. The Jamf Universal API (UAPI) is one such case, it is JSON only and not XM. Those tried and true xpath snippets will no longer work with JSON, in fact what tool do [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,46,37,12],"tags":[48,47,30,34,50],"class_list":["post-891","post","type-post","status-publish","format-standard","hentry","category-bash","category-jamf","category-jpt","category-scripting","tag-api","tag-jamf","tag-jpt","tag-json","tag-uapi"],"_links":{"self":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/comments?post=891"}],"version-history":[{"count":3,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/891\/revisions"}],"predecessor-version":[{"id":897,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/891\/revisions\/897"}],"wp:attachment":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/media?parent=891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/categories?post=891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/tags?post=891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}