Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2018-09-28 01:55 PM
I'm trying to update a single record via powershell but getting: "Server was unable to process request. ---> Input string was not in a correct format."
XML
<UpdateRecord><Field id="15858" type="4" value="Locked"/></UpdateRecord>
Powershell
$XML = "<UpdateRecord><Field id=`"$($FieldID)`" type=`"4`" value=`"Locked`"/></UpdateRecord>";
$ArcherRecordWSDL.UpdateRecord($ArcherSession,$ModuleID,$ArcherRecordID,$XML);
Request
POST /ws/record.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://archer-tech.com/webservices/UpdateRecord"
Host: grcb.archer.rsa.com
Content-Length: 550
Connection: close
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><UpdateRecord xmlns="http://archer-tech.com/webservices/"><sessionToken>{Intentionally Removed}</sessionToken><moduleId>424</moduleId><contentId>379015</contentId><fieldValues><UpdateRecord><Field id="15858" type="4" value="Locked"/></UpdateRecord></fieldValues></UpdateRecord></soap:Body></soap:Envelope>
Response
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/xml; charset=utf-8
X-FRAME-OPTIONS: SAMEORIGIN
Set-Cookie: dtCookie=1$15506CFE24F85CFF3E79214E871B7C5C;Secure; Path=/; Domain=.rsa.com
Date: Fri, 28 Sep 2018 17:31:39 GMT
Content-Length: 429
Connection: close
Strict-Transport-Security: max-age=15552000
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---> Input string was not in a correct format.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
I'm currently using BurpSuite to troubleshoot and make changes outside powershell. Anyone have any idea why this is not working?
2018-09-28 04:06 PM
Here is my complete PowerShell script to create and then update a record in the Facilities application.
[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12","Tls11","Tls","Ssl3")
# Set the Instance information.
$base_url = "http://localhost/RSAarcher"
$instance_name = "Archer"
$user_domain = ""
$username = "apiuser"
$password = "Password123$"
# LOGIN to get the session token using Web Services API. Display the session token or exit.
try
{
$api_url = $base_url + "/ws/general.asmx"
$ws = New-WebServiceProxy -Uri $api_url -Class General -Namespace webservice -ErrorAction Stop
if ($user_domain -eq "") {
$session_token = $ws.CreateUserSessionFromInstance($username, $instance_name, $password)
}
else {
$session_token = $ws.CreateDomainUserSessionFromInstance($username, $instance_name, $password, $user_domain)
}
$session_token
}
catch {
$session_token = $null
$_.Exception|Format-List -Force
exit
}
# Create record.
$api_url = $base_url + "/ws/record.asmx"
$ws = New-WebServiceProxy -Uri $api_url -Class Record -Namespace webservice
$moduleId = 69 # Facilities
$xml = '<fieldValues><Field id="129" name="Facility Name" value="Created by PowerShell"/></fieldValues>'
$contentId = $ws.CreateRecord($session_token, $moduleId, $xml)
$contentId
pause # to confirm the record via UI.
# Update record created above.
$xml = '<fieldValues><Field id="129" name="Facility Name" value="Updated by PowerShell"/></fieldValues>'
$res = $ws.UpdateRecord($session_token, $moduleId, $contentId, $xml)
$res
2018-09-28 02:03 PM
For the XML, replace UpdateRecord with fieldValues:
<fieldValues><Field id="15858" type="4" value="Locked"/></fieldValues>
Also, to avoid having to escape the double-quotes, enclose value in single ticks:
$XML = '<fieldValues><Field id="15858" type="4" value="Locked"/></fieldValues>'
2018-09-28 02:18 PM
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateRecord xmlns="http://archer-tech.com/webservices/">
<sessionToken></sessionToken>
<moduleId>424</moduleId>
<contentId>379015</contentId>
<fieldValues><Field id="15858" type="4" value="Locked"/></fieldValues>
</UpdateRecord>
</soap:Body>
</soap:Envelope>
I'm now getting: "Server was unable to process request. ---> Level Id could not be determined"
2018-09-28 02:20 PM
If you are creating the full SOAP call, enclose XML values within CDATA...check out the very end of KB https://community.rsa.com/docs/DOC-45642
2018-09-28 02:23 PM
Actually, you need to include <fieldValues> again. Once for the parameter name and once in the value itself to enclose the <Fields> (XML escaped).
<fieldValues><fieldValues><Field id="15858" type="4" value="Locked"/></fieldValues></fieldValues>
2018-09-28 02:25 PM
do you mean if i'm creating the SOAP request manually? I'm currently utilizing WSDL to make the calls
2018-09-28 02:29 PM
Also, check out my comments at the end of Parameter error when using SOAP API to create case that may help explain better with examples.
2018-09-28 02:42 PM
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateRecord xmlns="http://archer-tech.com/webservices/">
<sessionToken></sessionToken>
<moduleId>424</moduleId>
<contentId>379015</contentId>
<fieldValues><fieldValues><Field id="15858" type="4" value="Locked"/></fieldValues></fieldValues>
</UpdateRecord>
</soap:Body>
</soap:Envelope>
"Server was unable to process request. ---> Input string was not in a correct format."
2018-09-28 04:01 PM
I tried adding the CDATA section but still no luck :/
2018-09-28 04:06 PM
Here is my complete PowerShell script to create and then update a record in the Facilities application.
[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12","Tls11","Tls","Ssl3")
# Set the Instance information.
$base_url = "http://localhost/RSAarcher"
$instance_name = "Archer"
$user_domain = ""
$username = "apiuser"
$password = "Password123$"
# LOGIN to get the session token using Web Services API. Display the session token or exit.
try
{
$api_url = $base_url + "/ws/general.asmx"
$ws = New-WebServiceProxy -Uri $api_url -Class General -Namespace webservice -ErrorAction Stop
if ($user_domain -eq "") {
$session_token = $ws.CreateUserSessionFromInstance($username, $instance_name, $password)
}
else {
$session_token = $ws.CreateDomainUserSessionFromInstance($username, $instance_name, $password, $user_domain)
}
$session_token
}
catch {
$session_token = $null
$_.Exception|Format-List -Force
exit
}
# Create record.
$api_url = $base_url + "/ws/record.asmx"
$ws = New-WebServiceProxy -Uri $api_url -Class Record -Namespace webservice
$moduleId = 69 # Facilities
$xml = '<fieldValues><Field id="129" name="Facility Name" value="Created by PowerShell"/></fieldValues>'
$contentId = $ws.CreateRecord($session_token, $moduleId, $xml)
$contentId
pause # to confirm the record via UI.
# Update record created above.
$xml = '<fieldValues><Field id="129" name="Facility Name" value="Updated by PowerShell"/></fieldValues>'
$res = $ws.UpdateRecord($session_token, $moduleId, $contentId, $xml)
$res