Custom Object for API

Skip to first unread message

Jan 25, 2018, 8:09:47 AM1/25/18
I am working with an API, and this one is requiring the first parameter passed to it be an object and not a string. I think I need to create an object and set the “.ID” string field to the value I am pulling from SQL.

$OSSNAWS = New-WebServiceProxy -Uri "http://localhost/websiteA/Web.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential

$applicationUri = ""

$extDeviceID = '00AA11BB22CC'

$devID = New-Object -TypeName PSObject

Add-Member -InputObject $devID -MemberType NoteProperty -Name Id -Value $extDeviceID

$devID.Id = $extDeviceID


The API is the “LaunchClientApplication” and the parameter that needs to be an object is the $devID.

When I run the above, this is the error I get back.

Cannot convert argument "0", with value: "@{Id=00AA11BB22CC}", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "@{Id=00AA11BB22CC}" value of type "System.Management.Automation
.PSCustomObject" to type "WebServiceProxy.ExternalId"."
At C:\PowerShellScripts\Test-.ps1:23 char:38
+ $OSSNBWS.LaunchClientApplication <<<< ($devID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

I’ve been playing around and researching this and cannot seem to get that parameter right. I feel that there is a rather simple solution that is just out of my reach.

Reply all
Reply to author
0 new messages