Skip to main content
Question

API - Web Service XML File Generation


Forum|alt.badge.img+9

Curious if anyone has used the API to generate current state XML file for computers in inventory. I want to CURL the output to an XML file and make it available to other systems. However, the issue I run into is WHEN to initiate the XML file creation and HOW to initiate it.

What the end state would be is a directory of unique XML files (using computer name as the file name; so one file per computer) that are consumable by other systems.

I'm thinking that a script to run after initial recon may do it, but would love feedback on that approach.

How would you do it?

3 replies

Forum|alt.badge.img+9
  • Author
  • Contributor
  • 124 replies
  • May 16, 2012

Looking at this, I think I could run a command like this:

#!/bin/sh
curl -u jssusername:jsspassword 
"https://jss/JSResource/computers/name/computerName/subset/General&Location&Extension_Attributes" -o filePath;

However, if this is run during Recon what user context is it running in? I'd like the "filePath" to be a network drive and would need to ensure that the permissions are set appropriately.


Forum|alt.badge.img+10
  • Valued Contributor
  • 230 replies
  • November 7, 2013

A relevant question here is what other kinds of systems are going to consume this data and how? 'Cuz I would generally think this information wants to live in a database not as a bunch of formatted flat files.


Forum|alt.badge.img+10
  • Valued Contributor
  • 230 replies
  • November 7, 2013

Forgot that I intended to be helpful. Depending on which computers records you want to export, you may be able to reverse the flow of this script somewhat:

http://bashscripts.org/forum/viewtopic.php?f=8&t=1330

JAFuller's basic idea is right; with curl you can also do globs so if you're looking at anything by IDs in the JSS... so to appropriate his curl from above as an example:

curl -u jssusername:jsspassword 
"https://jss/JSSResource/computers/id/[1-9]/subset/General&Location&Extension_Attributes" -o filePath#1.xml

This would collect computers with id 1-9... You could likely also create collections to get the just the computers you want organized in such a way that you can serially retrieve them with a much smaller list than everything in your JSS.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings