bitcoin rpc api createrawtransaction with python returns -3: Expected type array, got object experimenting with JSON RPC API using bitcoinrpc.authproxy for python.

so far it works in all instances accept when i try to create a raw transaction.
somewhere along the way im passing parameters in wrong format. 

i created helper methods to create my inputs/outputs like this: 

def getTransactionJsonInput(self, sourcetransaction) -&gt; str: 
    return {"txid": sourcetransaction['txid'] ,"vout":sourcetransaction['vout']}

def getTransactionJsonOutput(self, new_address, amount, returnaddress, returnamount) -&gt; str: 
    return {
        new_address: amount,
        returnaddress: returnamount
    }


and when i print my call to createrawtransaction it appears to be correct 

    print('TRANSACTION inputs', [input], type([input]))
    print('TRANSACTION outputs', output, type(output))
    return svc.createrawtransaction(input, output)



  TRANSACTION inputs [{'txid': 'sourcetransactionid', 'vout': 1}] &lt;class 'list'&gt;
  
  TRANSACTION outputs {'destinationaddress': 0.012, 'changeaddress': 2.56559703} &lt;class 'dict'&gt;


error: 


  bitcoinrpc.authproxy.JSONRPCException: -3: Expected type array, got object


solution

thanks to @m1xolyd1an i was steered in the right direction. All that was missing in my implementation was adding [] around inputs. i added them in print statement but not in the actual call! 

before

return svc.createrawtransaction(input, output)


after

return svc.createrawtransaction([input], output)


new result: 


  new transaction:  0200000001005134d493cb536a5000b491b0b6dbca6c5187eec67ffb8769fdedac9ec25db40100000000ffffffff02804f12000000000017a914190150e1a961a2509b1d48c4d6cf6b644454cd968757ca4a0f0000000017a91496711dceda7240a6c492b2fabc5d44ab5d4bd19e8700000000
You are providing it an Object in JSON, not an array just as the error states. 

 return {"txid": sourcetransaction['txid'] ,"vout":sourcetransaction['vout']}


I would try creating it from a dictionary and then adding it to a list instead of building it from a string, something like: 

&gt;&gt;&gt; inputs = {}   #create the dictionary
&gt;&gt;&gt; inputs["txid"]=sourcetransaction['txid']  #add the value to the dictionary key 'txid'
&gt;&gt;&gt; inputs["vout"]=sourcetransaction['vout']  #add nout value to key 'vout'  

&gt;&gt;&gt; inputs
{'txid': 'a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c', 'vout': 0}

&gt;&gt;&gt; inputsList=[inputs] #add dictionary input to list 
&gt;&gt;&gt; inputsList
[{'txid': 'a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c', 'vout': 0}]


Also noted in the example from the source:     

def createrawtransaction(self, inputs, outputs):
    """
    Creates a raw transaction spending given inputs
    (a list of dictionaries, each containing a transaction id and an output number),
    sending to given address(es).
    Returns hex-encoded raw transaction.
    Example usage:
    &gt;&gt;&gt; conn.createrawtransaction(
            [{"txid": "a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c",
              "vout": 0}],
            {"mkZBYBiq6DNoQEKakpMJegyDbw2YiNQnHT":50})
    Arguments:
    - *inputs* -- A list of {"txid": txid, "vout": n} dictionaries.
    - *outputs* -- A dictionary mapping (public) addresses to the amount
                   they are to be paid.
    """
    return self.proxy.createrawtransaction(inputs, outputs)