I am trying to update a custom field in an application via the applications API. The documentation states I need to serialize and then encode a response giving the PHP example of:
'customfields' => base64_encode(serialize(array("1"=>"Yahoo")));,
However, I am working in PowerShell. I think the below will work for the encoding part of this, but I'm not sure how I would serialize the array first.
$Encodeddata = [Convert]::ToBase64String($data)
The full documentation of this API is here:
https://developers.whmcs.com/api-reference/updateclientproduct/
So far the solution for this I have looks like this :
$data = @{}
$data.add("1","Frank")
$sData = ConvertTo-JSON $data
$Encodeddata =[Convert]::ToBase64String($sdata)
But I get the following error:
Cannot convert argument "inArray", with value: "{
"1": "Frank"
Which suggests to me that the result of converting to Json is still an array. Im not sure how to get past that.