Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

API created Request and need to set variables on the form.

clyon
Tera Guru

Hi, I'm using the following order_now API to create a Request. How can I specify the values of the Requested_for, Opened_by, Description fields via the API call. The workflow associated creates the RITM and Task and the values I set on the Request I need to have populated on the RIMT and Task as well.

 

https://xxxxx.service-now.com/api/sn_sc/servicecatalog/items/022390031b013380c0b8dd7edd4bcb17/order_now

Request Body:

{\"sysparm_quantity\":\"1\",\"requested_for\":\"5851485337cc02001108a9c2b3990ed1\",\"opened_by\":\"bf6f4a1e1b69bb00c0b8dd7edd4bcb24\",\"requestor\":\"5851485337cc02001108a9c2b3990ed1\",\"short_description\":\"Vending Machine Purchase\"}";

 

TIA

 

6 REPLIES 6

Mike Patel
Tera Sage

I am using the OrderNow api. I did see where you could specify the variables. I have updated my requestbody to look like this:

{"sysparm_quantity":"1","variables":"{requested_for:'5851485337cc02001108a9c2b3990ed1',opened_by:'bf6f4a1e1b69bb00c0b8dd7edd4bcb24',requestor:'5851485337cc02001108a9c2b3990ed1',short_description:'CAL Vending Purchase',description:'who price desc'}"}

I am getting a 404 Not Found.  Any thoughts as to what's wrong with the request body?

 

did you tried below

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_CJSS-orderNow_O

{
  'sys_id' : item_id,
  'sysparm_quantity' : item_quantity,
  'sysparm_requested_for' : requested_for,
  'variables' : {
    'var_name' : 'var_value',
    ...
  }
}

clyon
Tera Guru

I have tried this and am able to get the variables to update. Is there a way to also update the Request and RITM Opened_by and Description fields? I tried to set sysparm_opened_by and sysparm_description but that didn’t work.

{
'sys_id' : '022390031b013380c0b8dd7edd4bcb17',
'sysparm_quantity' : '1',
'sysparm_requested_for' : '5851485337cc02001108a9c2b3990ed1',
'variables' : {
'requested_for':'5851485337cc02001108a9c2b3990ed1',
'short_desc': 'CAL Vending Purchase',
'detailed_desc': 'Price- $5'
}
}