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

Adding CI using API interface

Sergey Lisitsin
Kilo Contributor

Hello everyone,

I am trying to write a script to import multiple CI's into CMDB using REST API interface. I am testing the deployment in Postman, create a POST request and receive the following data:

 

"result": {
        "items": [
            {
                "className": "cmdb_ci_router",
                "sysId": "Unknown",
                "identifierEntrySysId": "Unknown",
                "errors": [
                    {
                        "error": "INVALID_INPUT_DATA",
                        "message": "In payload invalid data source [null] exist. You need to provide a valid choice value from field [discovery_source] in table [cmdb_ci]"
                    }
                ],
                "identificationAttempts": [],

Obviously the error message suggests that field [discovery_source] is missing the correct info. I have tried to leave the field blank, putting in "None" or other name of existing discovery source, but still get the same error. Does it need to be an ID of a discovery source and if so, where do I find it?

Thanks

1 ACCEPTED SOLUTION

can u try something like below ? 

{
  "attributes": {
    "name" : "New_PC"
  },
  "source": "ServiceNow",

}

View solution in original post

13 REPLIES 13

Ravi9
ServiceNow Employee
ServiceNow Employee

can u share ur rest api end point ? is it custom or oob ? 

Hi Ravi, thank you for your reply. Sorry, but I'm not sure what you mean by rest api endpoint. If it is the URL, then it is 

https://dev94109.service-now.com/api/now/v1/cmdb/instance/cmdb_ci_computer

 

 

ya this is what i was looking for , seems custom to me , at least i cant find this in my personal instance 

if u r familiar with SN dev and code then you will have to go here 

https://YOUR_INSTANCE_NAME.service-now.com/sys_ws_operation_list.do?sysparm_query=operation_uriLIKEcmdb_ci_computer&sysparm_view= 

above is a sample link - put ur instance details in highlighted one and then see if u get any record in the list view , am assuming u will , hopefully one 🙂 

u can look through the code to understand what param / validation it has which is causing ur error , if not sure u can share the code / screenshot here as well 

I am able to do a GET request successfully and do get a list of all the computer CIs from CMDB. Just not sure why I can't ignore the discovery_source field when trying to add the new one.