There are many inquiries that customers would like to upload many records from a CSV or an Excel file. Tulip has a CSV import function, but we need to select each field to match before uploading. So, It’s difficult to upload a CSV file automatically.
If Tulip API can accept array of objects as POST method, we will be able to upload multiple records to a table at one transaction. Right now, we have to use Node-RED to read and send a line of a CSV file one by one.
A workaround is to build your json payload by transforming an array in string with delimiter as , « key » = we use it a lot for POST with array in the payload
Hello Youri,
Thank you for your answer, but I didn’t get it - can you please give an example of how a sample multi-record payload looks like?
And if possible, the code which generates it?
I didn’t notice your post. Sorry. But I would like you to give us a sample of how to create msg.body for multiple records. I encountered 400 error when I put msg.body like below.
I am also curious about this. I thought the only way to create multiple records was multiple API requests. Certainly there is nothing in the API docs suggesting otherwise… I am using python, not node red. I think I know what you’re talking about as far as building a string with the comma delimiter, I have to do a similar construction for querying the database to find all records matching some list of ID’s.
Here is the code for anyone curious:
def list_format(id_list):
"""Creates a list of values that can be used in Tulip API requests
with an isIn filter. Primarily intended for taking a list of IDs
connected to a test plan and returning all results from the
sample or Test Results table matching those IDs"""
if len(id_list) != 0:
id_list_string = ''
for i in range(len(id_list)):
if i == 0 and len(id_list):
id_list_string += "[" + "\"" + id_list[i] + "\""
else:
id_list_string += f"\"{id_list[i]}\""
if i != (len(id_list) -1):
id_list_string += ","
if i == (len(id_list) - 1):
id_list_string += "]"
return id_list_string