The CreatorCon Call for Content is officially open! Get started here.

Updating cost_center using REST API

kshitishchodank
Mega Contributor

Hi Guys,

I am trying to update the cost center, location of a user in ServiceNow(Geneva) using REST api. I am using

https://devxxxxx.service-now.com/api/now/v1/import/(table) with POST type.

My input is

{

      "cost_center":" ",

      "user_sys_id":"<user-id>"

}

This gives me "No field values changed" message. When I change the type to patch with the following url

https://devxxxxx.service-now.com/api/now/v1/import/(table)/<user-id>

I get "Method not Supported" message.I even tried with X-http-method-override but it wasn't helpful. I went through this doc but was not able to understand what I was doing wrong. Please advice.

1 ACCEPTED SOLUTION

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Kshitiah,



As you are on Geneva and using an import set table this is the documentation URL that refers:


Import Set API



The import set table needs to be specified


Only POST and GET are supported methods - PUT and PATCH are not possible.


However a POST to import set table imp_user will update an existing user record based on user_id.



Any questions arising add them to this thread 🙂



If the reply was informational, please like, mark as helpful or mark as correct!




Also there is a sample CURL request mentioned:


curl "https://instance.service-now.com/api/now/import/imp_user" \
--request POST \
--header "Accept:application/json"\
--header "Content-Type:application/json" \
--data "{'first_name':'John','last_name':'Public','user_id':'john.public','email':'john.public@company.com'}" \
--user 'admin':'admin'





View solution in original post

7 REPLIES 7

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Kshitiah,



As you are on Geneva and using an import set table this is the documentation URL that refers:


Import Set API



The import set table needs to be specified


Only POST and GET are supported methods - PUT and PATCH are not possible.


However a POST to import set table imp_user will update an existing user record based on user_id.



Any questions arising add them to this thread 🙂



If the reply was informational, please like, mark as helpful or mark as correct!




Also there is a sample CURL request mentioned:


curl "https://instance.service-now.com/api/now/import/imp_user" \
--request POST \
--header "Accept:application/json"\
--header "Content-Type:application/json" \
--data "{'first_name':'John','last_name':'Public','user_id':'john.public','email':'john.public@company.com'}" \
--user 'admin':'admin'





Thanks , yes you are correct. Patch and Put are not available for import set table. I am not able to update fields like cost center and location. Any idea how this can be possible? May be I will open another thread for this.


Hi Kshitish,



If you can specify a cost center or location via user list view,   ie   the value you specify already exists in the location and cost center table, you should be able to populate via REST api.



If the reply was informational, please like, mark as helpful or mark as correct!