Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2019-04-10 03:00 AM
I am working on one request where I need to download all the attachment from an application. I tried by using GetAttachmentFile , but still it doesnot works.
2019-04-10 09:37 AM
I've moved your question to the RSA Archer Customer/Partner Community" data-type="space space where it will be seen by the product's support engineers, other customers and partners. Please bookmark this page and use it when you have product-specific questions.
Alternatively, from the RSA Customer Support" data-type="space page, click on Ask A Question on the blue navigation bar and choose Ask A Product Related Question. From there, scroll to RSA Archer Suite" data-type="space and click Ask A Question. That way your question will appear in the correct space.
Regards,
Erica
2019-04-10 09:44 AM
Abhishek, can you post the SOAP call you're using?
More on, https://community.rsa.com/docs/DOC-98592
Advisory Consultant
2019-04-10 03:10 PM
Hi David,
I used below SOAP as a reference:
<soap:Body>
<GetAttachmentFileResponse xmlns="http://archer-tech.com/webservices/">
<GetAttachmentFileResult>string</GetAttachmentFileResult>
</GetAttachmentFileResponse>
</soap:Body>
</soap:Envelope>
Additonally, I also tried record.GetAttachmentFile($session_token, 436); but it is returning "</File>"
It would be great if you could provide me some reference related to powershell?
Thanks for the help!!
2019-04-10 03:15 PM
Thanks, the link I posted in my initial response is to the doc that tells you how to construct the SOAP request to get the file and what's expected when successful.
SOAP Request
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAttachmentFile xmlns="http://archer-tech.com/webservices/">
<sessionToken>string</sessionToken>
<fileId>int</fileId>
</GetAttachmentFile>
</soap:Body>
</soap:Envelope>
Advisory Consultant
2019-04-10 03:31 PM
Thank you so much, David
2019-04-10 06:24 PM - edited 2021-07-23 03:28 PM
To download Attachments using REST API, check out the attachment sections in the Content segment.
REST API call to download:
Verb: GET
URL: /api/core/content/attachment/*attachmentid*
Sample Response for /api/core/content/attachment/23
{
"Links": [],
"RequestedObject": {
"AttachmentBytes": "R0lGODlhDwAPAKECAAAAzMzM/////wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4MLwWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw==",
"AttachmentName": "image.png"
},
"IsSuccessful": true,
"ValidationMessages": []
}
The following PowerShell shows how to download attachments to disk using a list of file ids:
# Set Instance info
$base_url = "http://web65/RSAarcher"
$instance_name = "Archer"
$user_domain = ""
$username = "apiuser"
$password = "Password123$"
# Login and get session token
$login_url = $base_url + "/api/core/security/login"
$body = '{"InstanceName":"' + $instance_name + '","Username":"' + $username + '","UserDomain":"' + $user_domain + '","Password":"' + $password + '"}'
$response_login = Invoke-RestMethod -Method Post -Uri $login_url -Body $body -ContentType "application/json"
if ($response_login.IsSuccessful) {
$session_token = $response_login.RequestedObject.SessionToken
} else {
Write-Warning "Unable to login with specified credentials"
exit
}
# Create headers
$headersGET = @{}
$headersGET.Add("Authorization", "Archer session-id=" + $session_token)
$headersGET.Add("X-Http-Method-Override", "GET")
$headers = @{}
$headers.Add("Authorization", "Archer session-id=" + $session_token)
# Get list of attachment file ids, loop thru them and save to disk.
$fileIds = @(23,24,999)
foreach($fileId in $fileIds) {
try {
$api_url = $base_url + "/api/core/content/attachment/$fileId"
$results = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -ContentType "application/json"
if($results.IsSuccessful) {
$bytes = [System.Convert]::FromBase64String($results.RequestedObject.AttachmentBytes)
$filename = $results.RequestedObject.AttachmentName
$filepath = "c:\temp\download\" + $filename
[IO.File]::WriteAllBytes($filepath, $bytes)
Write-Host $filepath
} else {
Write-Warning ("Downloading File Id $fileid failed. " + ($results.ValidationMessages.Description | Join-String))
}
}
catch {
Write-Warning ("Unexpected error processing File Id $fileid. " + $_.Exception.Message)
}
finally {
$results=$null; $bytes=$null; $filename=$null; $filepath=$null
}
}
PowerShell Output:
2019-04-11 02:10 AM
Thank you jeff, It is really helpful.
2019-04-11 02:42 AM
Hi Jeff,
I am getting below error as attached:
2019-04-11 05:13 AM
Hi Jeff,
I resolved the issue. Thanks for your support.