(SM) Support Tip: REST JSON payload(s) to update multiple records using JavaScript

Hello SM Community,

  In some scenarios it would be faster to use a single POST to update several records in SM via REST, this is however not yet possible on SM (ER open for this QCCR1E134475 REST API - Required JSON payload to update multiple records in single POSTand in order to use POST udpates we would need to modify manually the URL to point an specific resource ID.

   On the meantime we enhace the REST API, we might need to use a custom JS to simulate this behavior or at least some code everyone can use as a base to start playing with the SM REST API - JS.

  Find below an example code that will receive a list of IDs, the values to modify and the collection/resoruce names, at the moment the code will assume the resource has only one KEY field and we are only updating one value, however the code can be easily adjusted to accept more KEYS or Fields to update.



   I used also two functions (  doRESTPostRequest and createBasicAuthHttpHeaders ) from the OOB SL smis_RestClient, however I did added them to my script because I had to adapt them to use Content-Type JSON (OOB it will use application/XML) and because for this post I guess is easier to have all the needed functions on a single file.



Again, this an example code where you can take some ideas from or at least understand how it works via JavaScript.

Attached is the SL UNL file with also an example where I am updating two contact's email address using the code. (NOTE: for REST URL creation, always remember to replace empty space characters with %2, so for example if the key field has empty spaces in between:


Once the Script is executed, you will get some prints with the ID that is being modified, the URL used, and the JSON payload:


Hope this helps, if so, don't forget to KUDO the post! 


  • Hello Enrique.

    Maybe you can help me.

    I'm doing an integration of HSPM with another system using REST.

    I can open the ticket in the other system but the parameters are not being sent.
    I tried to pass the parameters directly through the url, but the function of the HTTPRequest returns error.
    I'm doing now via json, but even the parameters are not being passed to the other system too.
    The following script is attached. If someone has an example of how to do it.

    Thank you so much.