Output format for $ws.SeachRecordsbyReport
I am trying to send a file to a location for another system to process. I created a report with 20 fields that is exactly what they need. If I export it to XML online it is in a format that is very useful. Such as this:
<?xml version="1.0" encoding="utf-8"?><ex:Record xmlns:ex="http://archertech.com/Print/Export"><ex:Item><ex:GEAR_ID>1</ex:GEAR_ID><ex:Office><ex:Item>GSA IT Acquisition (IQ)</ex:Item></ex:Office><ex:System_Name>Acquisition Planning Module (APM)</ex:System_Name><ex:Operated_By><ex:Item>Federal</ex:Item></ex:Operated_By><ex:FIPS_Impact_Level><ex:Item>Moderate</ex:Item></ex:FIPS_Impact_Level>
However if I use the $ws.SearchRecordsByReport command in an Powershell API script to save this report like this:
"Page " + $page
[xml] $xdoc = $ws.SearchRecordsByReport($session_token, $report_id, $page)
$xdoc.InnerXml | Out-File -filepath $FileForGEAR -Append -encoding ascii -Width 120
} While ($xdoc.Records.Record.Count -gt 0)
I get something else like this:
<?xml version="1.0" encoding="utf-16"?><Records count="209"><Metadata><FieldDefinitions><FieldDefinition id="21415" guid="99fb121f-00ce-4838-99e0-0f6348885f84" name="System Name" alias="System_Name" /><FieldDefinition id="21416" guid="8709ab9e-228e-4ed3-a372-4e8be3b6477e" name="Office" alias="Office" /><FieldDefinition id="21418" guid="38c23e3b-d6ad-4130-89e3-9ec77690a765" name="Operated By" alias="Operated_By" /><FieldDefinition id="21419" guid="e8c88dc1-c4e2-4c8d-87b7-0411ceb759fc" name="FIPS Impact Level" alias="FIPS_Impact_Level" /> .........
Removed 24 lines for simplicity
.......1</Field><Field id="21416" guid="8709ab9e-228e-4ed3-a372-4e8be3b6477e" type="9"><Reference id="224938">GSA IT Acquisition (IQ)</Reference></Field><Field id="21415" guid="99fb121f-00ce-4838-99e0-0f6348885f84" type="1">Acquisition Planning Module (APM)</Field><Field id="21418" guid="38c23e3b-d6ad-4130-89e3-9ec77690a765" type="4"><ListValues><ListValue id="74128" displayName="Federal">Federal</ListValue></ListValues></Field>
My questions are:
- Is this command the proper way to retrieve the report or do I need to breakdown and actually create a program to pull in these 20 fields?
- I am using PowerShell, is this something that can be done better using Visual Studio with Rest API?
- I know I could email this report as an XML but we are trying to save the file to a location without human intervention. If there is a way that it could be email to a file location please let me know.
- API Users
- Archer API
- RSA Archer
- RSA Archer API Users
- RSA Archer Suite
When you export to XML from the Archer interface you do not get the field metadata that you do when you use the webservices.
I personally have been using .net to create our exports. I am, however, creating it in the form of a .csv. But, I'm sure you could leave it as XML and parse out the header metadata.
Regarding your third question... I'm not suggesting if, but if this is your requirement, you could email the report to a group mailbox and use another application to pull it and post the file.
However, if you have to build that application, it would seem like equal development effort to just creating an application pulls the report and export to an XML file.