CORE: Set the task_for in RITM while creating through REST API

Arjun Thakur
Tera Contributor

Hello,

 

Need to set TASK_FOR in RITM, while calling catalog API (sn_sc). The rest API is called using service account. The task_for is getting value of service account.

 

I tried following payload, but task_for, opened_by, requested_for would not update to specific user. 

 

{
"sysparm_quantity": "1",
"requested_for": "d6d9285e1b2350d031070fedee4bcbce",
"opened_by": "d6d9285e1b2350d031070fedee4bcbce",
"task_for": "d6d9285e1b2350d031070fedee4bcbce",
"variables": {
"var1": "value"
}
}

 

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @Arjun Thakur 

 

In ServiceNow, when creating a Requested Item (RITM) through the Service Catalog API (sn_sc), setting the task_for, opened_by, and requested_for fields requires the use of the correct REST API endpoint and the correct payload format.

 

  1. Use the sn_sc/servicecatalog/items/createRequest endpoint.

  2. Make a POST request to this endpoint.

Sample payload -

 

{
  "sysparm_quantity": "1",
  "cat_item": "Catalog Item Sys ID", // Replace with the sys ID of the catalog item
  "variables": {
    "var1": "value",
    "opened_by": "User Sys ID", // sys ID of the user who opened the request
    "requested_for": "User Sys ID", // sys ID of the user for whom the request is made
    "task_for": "User Sys ID" // sys ID of the user for whom the task is created
  }
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar