• Custom Object for API

    From jasoncannon@ftc.org@21:1/5 to All on Thu Jan 25 05:09:45 2018
    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 = "http://websiteB.com/Apps/SMessages/MPage.aspx"

    $extDeviceID = '00AA11BB22CC'

    $devID = New-Object -TypeName PSObject

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

    $devID.Id = $extDeviceID

    $OSSNBWS.LaunchClientApplication($devID,$applicationUri)

    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.

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)