I figured it out!
You need to parse the response body and add the array to a named property for output fields to access it.
... execute: lambda do get('https://jsonplaceholder.typicode.com/comments').after_response do |code, body, headers| { comments: body } end end, ...
The list is now showing up.
FYI, after the new code block, the output fields block also needs to be updated to match the field name:
output_fields: lambda do [ { name: "comments", type: "array", of: "object", properties: [ { name: "id" }, { name: "postId" }, { name: "name" } ] } ] end
You can find more info about this and other methods here: SDK - HTTP Methods | Workato Docs
Thanks for this.
Send us a ticket, we will try our best to assist you with your problem
Aalaap Ghag
Error: undefined method `to_hash' for #<Array:0x00007f6d738a0808> while capturing array as output fields
I'm trying to parse out an array response from an API call, but I can't figure it out. The API call is to https://jsonplaceholder.typicode.com/comments, which returns the following response:
This is my connector code:
No matter what I try, the error I receive is:
undefined method `to_hash' for #<Array:0x00007f6d738a0808>
What am I doing wrong?
1 person likes this idea