yesterday
I am trying to format a request payload to be an array of objects, but it appears that the payload HTTP method defaults to formatting it as a hash such as
{
email: "exampleemail",
name: "John Jacob Jingleheimer Schmidt"
}
However, it needs to be enveloped in an array like as follows:
[
{
email: "exampleemail",
name: "John Jacob Jingleheimer Schmidt"
}
]
The payload HTTP method does not accept arrays, as this will throw an error. Is there a way to do this? What are your thoughts on this?
yesterday
I just tested this and the HTTP request payload (specifically for a POST) will accept an array without issue. You may be encoding it incorrectly. Can you provide more details on the error you receive?
41m ago
I tried enveloping the hash in an array in the following manner:
request_payload = {"data" => {"email" => "exampleemail", "name" => "John Jacob Jingleheimer Schmidt"}}
arrayed_req_payload = [request_payload['data']]
post(url).payload(arrayed_req_payload || {})
But I get an error saying undefined method `to_hash' for [nil]:Array at line: xxx where the line is the payload method. It's as if it is trying to convert it to a hash.
20m ago
Ah, you're in the connector SDK. This is interesting...
Looking at the SDK docs, it does indeed look like it's trying to hash whatever you put inside payload. I recommend checking with support about this. Sorry I couldn't be more help!