Entity always return "null". What's wrong?

So I got schema with 2 fields: id and name
I sending API call like that:

schema “v2”
data = generate 1
data[‘name’] = entity[‘name’]
data

curl -H “X-API-Key: 47fda570” -X POST -d ‘{“name”:“random_POSTname”}’ https://my.api.mockaroo.com/v2.json

and Instead of getting name: “random_POSTname” I’m getting response:

{“id”:1,“name”:null}

Is “entity” option working correctly?

I don’t have experience with the v2 version of the interface, so I can only provide you an answer for the methods described at the API documentation page.

What I noticed is that {"id":1,"name":null} is always the default output, so there is something wrong in your request.

I do not know which operating system you are using, but you can not use single quotes in windows (command prompt) to surround a parameter.

Also try to understand the API reference, because this is not how the parameters work: You have to provide a JSON array with n objects each containing at least a name attribute and a type attribute.

What I did to make it work in your case is:

  1. use the “old” api
  2. Provide an Array
  3. Add an object with name=name, type=Blank, formula=“random_POSTname”

With the double quote escaping of the Windows command line, it gets a bit messy, so please consider using a file as data instead of cmd parameters.

Solution:
curl "https://api.mockaroo.com/api/generate.json?key={{YOUR_API_KEY}}&count=5" -d "[{"""name""":"""name""","""type""":"""Blank""","""formula""":"""'random_POSTname'"""}]"

Please change {{YOUR_API_KEY}} with the relevant value (maybe you want to remove it from your original question too, to prevent abuse).