Help with Bulk_Create API

I’m trying to use the python rest API here to bulk create devices using an existing recipe. I can’t figure out what the “bulk_info” property should be.

Whenever I send a rest request, I just receive the following response:
{u'failed': 0, u'csvResult': u'', u'created': 0}

Looking at the following example that shows how to directly upload a csv, I am able to successfully upload and create devices using the following CSV:

Name,Description,internal_id
aaa,asdf,1
bbb,asdf,2
ccc,asdf,3

I cannot figure out what combination of CSV the server expects as the bulk info.

The schema example is here which says the bulk info should be straight forward but it’s not entirely obvious. Example schema below:

{
  "nameColumn": "myNameColumn",
  "descriptionColumn": "column2",
  "csv": "a,comma,separated,string,of,input,data"
}

Here’s my example code that is not working:

my_bulk_info =   { 
                    "nameColumn": "Name",
                    "descriptionColumn": "Description",
                    "csv": "aaa,asdf,bbb,asdf,ccc,asdf",
                    "makeUniqueKeySecret":True 
                 }

client = Client(auth_token=API_ACCESS_TOKEN)

result = client.device_recipe.bulk_create(
    applicationId=APPLICATION_ID,
    deviceRecipeId=DEVICE_RECIPE_ID,
    bulkInfo=my_bulk_info)

print result

For the csv string, the first line in the string is expected to be a header row, so for example, in your case you would want the string to be something like "Name,Description,internal_id\naaa,asdf,1" (note the newline char). I definitely agree the current example in the documentation is lacking - I will file a ticket to improve that documentation!
`

Thanks so much! The \n was key. All is working now.

Great, glad you got it working!