Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble with UpdateRecord()

RaulMartinez
Contributor II

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>&lt;UpdateRecord&gt;&lt;Field id="15858" type="4" value="Locked"/&gt;&lt;/UpdateRecord&gt;</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. ---&gt; 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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

12 REPLIES 12

JeffLetterman
Archer Employee
Archer Employee

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>‍‍'‍‍

<?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>&lt;Field id="15858" type="4" value="Locked"/&gt;</fieldValues>

   </UpdateRecord>

</soap:Body>

</soap:Envelope>

I'm now getting: "Server was unable to process request. ---&gt; Level Id could not be determined"

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 

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>&lt;fieldValues&gt;&lt;Field id="15858" type="4" value="Locked"/&gt;&lt;/fieldValues&gt;</fieldValues>

do you mean if i'm creating the SOAP request manually? I'm currently utilizing WSDL to make the calls

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.

<?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>&lt;fieldValues&gt;&lt;Field id="15858" type="4" value="Locked"/&gt;&lt;/fieldValues&gt;</fieldValues>

      </UpdateRecord>

   </soap:Body>

</soap:Envelope>

"Server was unable to process request. ---&gt; Input string was not in a correct format."

I tried adding the CDATA section but still no luck :/

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