0

Adapting a VBNet code example:

'Uses XML-RPC.NET 2.5.0 written by Charles Cook
'https://www.nuget.org/packages/xmlrpcnet/2.5.0

Imports CookComputing.XmlRpc

<XmlRpcUrl("https://www.upcdatabase.com/xmlrpc")> _
Public Interface IUPCDatabase
    Inherits IXmlRpcProxy

    <XmlRpcMethod("help")> _
    Function Help() As XmlRpcStruct

    <XmlRpcMethod("lookup")> _
    Function Lookup(ByVal struct As XmlRpcStruct) As XmlRpcStruct

End Interface

Public Class Form1
    Const RPCKEY As String = "0000000000000000000000000000000000000000" 'Replace with your own RPCKey
    Private _proxy As IUPCDatabase

    Private Function GetDescription(ByVal strUPC As String) As String
        Dim request As New XmlRpcStruct
        Dim response As New XmlRpcStruct

        'Validate(strUPC) 'Your own method to Trim and/or expand UPCE if needed UPCCode submission should be in UPCA Format

        request.Add("rpc_key", RPCKEY)
        request.Add("upc", strUPC)

        response = _proxy.Lookup(request)

        Return response("description") & " " & response("size")
    End Function

End Class

powershell error:

PS /home/nicholas/powershell> 
PS /home/nicholas/powershell> $response = Send-XmlRpcRequest -Url "http://www.upcdatabase.com/" -MethodName "lookup" -Params @('0012000000850','4________________________a3') 
Exception: /home/nicholas/.local/share/powershell/Modules/XmlRpc/1.0.1.1/XmlRpc.psm1:323
Line |
 323 |              $doc.LoadXml($response)
     |              ~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "LoadXml" with "1" argument(s): "'src' is an unexpected token. The expected token is '='. Line
     | 29, position 15."

PS /home/nicholas/powershell> 

I've tried a few different ways to "send" the params with this module but still get the same error.

Do I send the key first as a param, then the UPC code? I've tried a few different ways.

While the error relates to a module, it's almost certain that I'm incorrectly invoking the xml-rpc calls:

nicholas@mordor:~/powershell$ 
nicholas@mordor:~/powershell$ head /home/nicholas/.local/share/powershell/Modules/XmlRpc/1.0.1.1/XmlRpc.psm1
#Requires -Version 2.0
<#
    .Synopsis
        This is a compilation of functions for XML RPC requests

    .Description


    .Notes
        Author   : Oliver Lipkau <oliver@lipkau.net>
nicholas@mordor:~/powershell$ 

0 Answers0