REST API: I am getting response data in json when i test the 'get' method, how to add these data to table?

swathigangadhar
Tera Expert

I have a third party endpoint, when i save it am getting only 'Default Get' method(no other methods are generated), when i test, am able to get all user details in 'Response' field (json format) , now i want to add these records to my sys_user table, how to do that?

1 ACCEPTED SOLUTION

Hi Swathi,



you need to parse the response using JSONParser() and iterate over the key value pairs


Can you share the response so that the script can be designed?



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Hi Swathi,



Are you getting 100+ user records in the JSON response?


If yes then the JSON has to be iterated and determined how much is the length and accordingly create user records


Can you share the json response which contains more than 5-10 repetition of the similar type so that the script can be designed.



{"UserID":"10001460","Name":"B. Swathi","FIrst Name":"B.","Last Name":"Swathi","Email":"","Company":"ABC Corp Limited","Company Code":"ABC0002","Building":"Nagar","City":"Cp Dist","Country":"INDIA","Department":"Support","Vertival":"Admin","Sub Vertical":"Admin","Gender":"Male","Business Phone":"","Location":"India","Manager":"Ashok","State":"Kar","Street":"kur","Time Zone":"","VIP":"","Pincode":"500"}



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Swathi,



Were you able to achieve your requirement? If yes then please mark the answer as correct, helpful and hit like. This helps in closing the thread for the question. Thanks in advance.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader