ServiceNow POST only one record per request?

Katie A
Mega Guru

I am trying to create a python script that does the following:

  • Parse a CSV file
  • Send the CSV file to a remote server via REST API

The code I have is working to parse the CSV file and convert it to a JSON object.

However, when it imports to ServiceNow server, only the first row is written.

NOTE: I think this is because the ServiceNow API can only handle ONE ROW PER REQUEST. I have confirmed this with the graphical REST API request creator. AS you can see in the screenshot, I am trying to load two rows of data. In my test, the first row is written and then is gets by the second row. Thus only one record is imported.

Question: Could this be an issue with ServiceNow processing the request, and how can I fix the issue?

Here is a wiki article which describes the python script template.

http://wiki.servicenow.com/index.php?title=Table_API_Python_Examples#gsc.tab=0

Message was edited by: Kathryn Amaral

1 ACCEPTED SOLUTION

Hi Frank, I was able to get this working by using the JSONv2 API.



The REST api only allows you to insert one record:http://wiki.servicenow.com/index.php?title=Table_API#POST_.2Fapi.2Fnow.2Fv1.2Ftable.2F.28tableName.2...



We are able to use JSONv2 to insert multiple records:http://wiki.servicenow.com/index.php?title=JSONv2_Web_Service#insert


View solution in original post

4 REPLIES 4

fschuster
ServiceNow Employee
ServiceNow Employee

Hi,



AFAIK the Inbound REST API is in fact processing your request row-by-row as of now.


I ran into the same thing last year and I got the information that this is working as designed - I don't know if we have any plans to change that but I'm happy to verify that.



As a workaround we just sent the whole JSON object to ServiceNow and decoded it on ServiceNow side. I admit it's not how it should be but it helped speeding up the import significantly.



Frank


Hi Frank, I was able to get this working by using the JSONv2 API.



The REST api only allows you to insert one record:http://wiki.servicenow.com/index.php?title=Table_API#POST_.2Fapi.2Fnow.2Fv1.2Ftable.2F.28tableName.2...



We are able to use JSONv2 to insert multiple records:http://wiki.servicenow.com/index.php?title=JSONv2_Web_Service#insert


fschuster
ServiceNow Employee
ServiceNow Employee

Great catch! Happy to hear you could solve it this way



Cheers.


Hey Katie...

Can you guide how did you configure JSONv2 API and how did you pass request data to it? If you could provide steps that would be helpful.