Unrelated String to Integer conversion error

I keep getting the following error:

{"error":"no implicit conversion of String into Integer"}

My API is setup as follows:

API url: https://my.api.mockaroo.com/getcontentlist/blog.json

schema "Content Item"
data = generate 9
data['category'] = params['category']
data

In my schema the category field is set up as a list with fixed values, “blog” being one of them.

This call works when my data = generate is 1, but fails on 9.

Am I doing something wrong?

When you generate a single record, a ruby Hash is returned. When you generate multiple records an array of hashes is returned. So you probably want something like:

data.each {|record| record['category'] = params['category']}

When generating more than 1 record.

Thanks, I updated my script to:

schema "Content Item"
record = generate 9
record.each {|record| record['category'] = params['category']}
record

And that worked perfectly.