REST API not able to populate choice value

Sanjeev Kumar1
Kilo Sage

Hi All,

I am using REST API to insert/update data in Windows Server (cmdb_ci_win_server).

In Opertaion system (os) column if API found existing value it is selected properly but if no matched value exist in system it will not updating value.

{
"name":"desktop-i1frftf-3",
"os":"Microsoft Windows 10 Home",
"operational_status":"1"
}

but if we run from background for update/insert, if os value does not exist in choice list it will inserted by script but it's showing in blue.

In this image first record is inserted by background Script. Second record inserted by REST API.

I hope REST API also insert data in system in same way as inserted by background Script.  

find_real_file.png 

10 REPLIES 10

simonbergstedt
Tera Guru

One way of doing it is to not use the direct API but instead create an inbound rest web service and use a transform map which allows you better control regarding choicelists (you can for example specify that the new option should be added to the list of choices) plus the ability to use script things before being updated/inserted.

 

The direct APIs are great if the data you are sending has the structure and value that your instance expects but that is rarely the case when working on integrations (and people for that matter) which makes inbound web services (sets) a great option. And if you want to go really fancy you can always look at scripted rest/soap APIs but you can come a long way by just using your own inbound web services.

 

https://docs.servicenow.com/bundle/helsinki-application-development/page/integrate/inbound-web-services/concept/c_InboundWebServices.html

 

ARG645
Tera Guru

I just ran a test in my SandBox. Table API doest create new choices , but skips them. You get a Blue color value in the choice field because its new value and you are forcing it via background script. 

Choice field value in Blue Color 

As my first response suggested, better to use Import set API and Transform map. 

-Aman Gurram

Hi,

ServiceNow provided any limitations of Table API ?

sk185225,

I searched a lot but I did not find any documentation that specifically entails limitations of Table API. Only thing I found that may be related to this thread is the below Link. 

Table API | FAQs

Thank you,

-Aman Gurram

ARG645
Tera Guru

Please close this thread if your question was answered. So that it may help others in future.