Start a new topic
Solved

[api] Sample Create assert dosen't work

Hi 


I try create a new assert with a api and your sample dosent work. 


view my json:

{ "cmdb_config_item": 
  {
     "user_id":"214",
     "department_id":"4",
     "impact":"2",
     "location_id":"america", 
     "assigned_on":"2014-07-18 03:54:18",
     "agent_id":"215", 
     "name":"Windows 8",
     "ci_type_id":"5000048508",
     "level_field_attributes":    
        {
           "product_5000048508":"windows_os",
           "vendor_5000048508":"microsoft", 
           "cost":"8000",
           "license_validity_5000048508":"24",
           "installation_date_5000048508":"2014-07-24 13:33:35",
           "license_expiry_date_5000048508":"2016-07-2413:33:35",
           "license_key_5000048508":"234-423-543-534",
           "version_5000048508":"2.0",
          "license_type_5000048508":"commercial",
          "installed_machine_5000048508":"Andreas laptop",
          "installation_path_5000048508":"null",
          "last_audit_date_5000048508":"2014-07-16 14:27:48"
          }
     }
}

 it is a same code in your api documentation. 


I launch this command ligne: 

  

curl -u myemail@mydomain.com  -H "Content-Type: application/json" -d '{ "cmdb_config_item":{"user_id":"214","department_id":"4","impact":"2","location_id":"america","assigned_on":"2014-07-18 03:54:18","agent_id":"215","name":"Windows 8","ci_type_id":"5000048508","level_field_attributes":{"product_5000048508":"windows_os","vendor_5000048508":"microsoft","cost":"8000","license_validity_5000048508":"24","installation_date_5000048508":"2014-07-24 13:33:35","license_expiry_date_5000048508":"2016-07-2413:33:35","license_key_5000048508":"234-423-543-534","version_5000048508":"2.0","license_type_5000048508":"commercial","installed_machine_5000048508":"Andreas laptop","installation_path_5000048508":"null","last_audit_date_5000048508":"2014-07-16 14:27:48"}}}' -X POST https://mydomain.freshservice.com/cmdb/items.json

  and the server return: 

{"status":false,"errors":"Product,Asset State is/are mandatory for a config_item"}


Can you help me to created an asset with your API?

Thanks

One week and no response? Any feedback about this?

Hey Arthur,


Sorry for the delayed response.


The sample API call wouldn't helped you since all the fields would require a valid field ID's, such like below.


{

 "cmdb_config_item":{

"user_id":"3001252747",

"department_id":"3000103148",

"impact":"2",

"location_id":"India",

"assigned_on":"2014-07-18 03:54:18",

"agent_id":"3000440643",

"name":"RODEO FX",

"ci_type_id":"3000747063",

"level_field_attributes":{

"product_3000747036":"Apple MacBook Air 13",

"vendor_3000747036":"Apple",

"cost":"8000","license_validity_3000747036":"24",

"installation_date_3000747036":"2014-07-24 13:33:35",

"license_expiry_date_3000747036":"2016-07-2413:33:35",

"license_key_3000747036":"234-423-543-534",

"version_3000747036":"2.0",

"asset_state_3000747036":"In Use",

"last_audit_date_3000747036":"2014-07-16 14:27:48"

}

}

}'

 

You can get the respective Field ID's upon a GET request for each page. Sample, If you like to get the ID's for Agent ID, you can GET the JSON from https://domain.freshservice.com/agents.json and then POST such above API's upon replacing with the required ID's.


You can pass the below curl command to make this happen,

curl -u test@domain.com:test -H "Content-Type: application/json" -d '{ "cmdb_config_item":{"user_id":"3001252747","department_id":"3000103148","impact":"2","location_id":"India","assigned_on":"2014-07-18 03:54:18","agent_id":"3000440643","name":"Asset Creation","ci_type_id":"3000747063","level_field_attributes":{"product_3000747036":"Apple MacBook Air 13","vendor_3000747036":"Apple","cost":"8000","license_validity_3000747036":"24","installation_date_3000747036":"2014-07-24 13:33:35","license_expiry_date_3000747036":"2016-07-2413:33:35","license_key_3000747036":"234-423-543-534","version_3000747036":"2.0","asset_state_3000747036":"In Use","last_audit_date_3000747036":"2014-07-16 14:27:48"}}}' -X POST  https://domain.freshservice.com/cmdb/items.json


Hope this helps you out.


Please feel free to write out to support@freshservice.com for further assistance. 


Login or Signup to post a comment