Update a single-value category with Api
-
Hi,
I'm trying to update the value of the Operating System category(C__CATG__OPERATING_SYSTEM) using json api.This is the request:
{ "version": "2.0", "method": "cmdb.category.update", "params": { "category": "C__CATG__OPERATING_SYSTEM", "objID": 6531, "data": { "application": 5771, "assigned_version": 9 }, "apikey": "******", "language": "en" }, "id": "1" }Response from the db:
{ "id": "1", "jsonrpc": "2.0", "error": { "code": -32603, "message": "Internal error: Validation errors in dialog related properties occured.", "data": { "assigned_version": "(dialog_plus) Id value(s) '9' do not exist in dialog table. Please check your provided selection." } } }I'm sure the value '9' mentioned in the error message exist. The problem only appears when updating, If I purge the category, then I can recreate it with the same data.
-
Hi @mirkomatonti
does the entry for "assigned_version" is the entry-id or the value in the i-doit gui?
If 9 is the value which can be selected in the dropdown menu in the gui, you need to write it with quotation marks for the api request
Extract:"data": { "application": 5771, "assigned_version": "9" <---------- },Furthermore, the update method is deprecated and I recommend to use the save method.
in your case this would looks like the following snippet:{ "jsonrpc": "2.0", "method": "cmdb.category.save", "params": { "category": "C__CATG__OPERATING_SYSTEM", "apikey": "*********", "language": en "object": 6531, "data": { "application": 5771, "assigned_version": "9" } }, "id": 1 }Cheers,
Phil -
Hi @Philipp-Hörselmann , thank you, changing to "value" it worked!
Now I have the same problem updating the "C__CATG__VIRTUAL_MACHINE".
If I run this on a new object everything goes fine:{ "version": "2.0", "method": "cmdb.category.save", "params": { "category": "C__CATG__VIRTUAL_MACHINE", "object": 6600, "data": { "virtual_machine": 2, "hosts": 834, "primary": 6597, "system": 10 }, "apikey": "******", "language": "en" }, "id": "1" }Let's say I want to change the "Running on host"' and the "Host in cluster" properties to (253,6444) respectively:
{ "version": "2.0", "method": "cmdb.category.save", "params": { "category": "C__CATG__VIRTUAL_MACHINE", "object": 6600, "data": { "virtual_machine": 2, "hosts": 253, "primary": 6444, "system": 10 }, "apikey": "******", "language": "en" }, "id": "1" }Same error:
{ "primary": "(dialog) Id value(s) '6444' do not exist in dialog table. Please check your provided selection." }The problem shows up only with the api, on the web GUI I can change them manually and if I do a category.read I get the correct updated values (hosts:253,primary:6444):
{ "id": "1", "jsonrpc": "2.0", "result": [ { "id": "290", "objID": "6600", "virtual_machine": { "id": "2", "title": "Yes", "const": "", "title_lang": "LC__UNIVERSAL__YES" }, "hosts": { "title": "Test Cluster", "id": "253", "connection_id": "2981", "type": "C__OBJTYPE__CLUSTER", "type_title": "Cluster", "sysid": "SYSID_1583768396" }, "system": { "id": "10", "title": "XEN", "const": null, "title_lang": "XEN" }, "config_file": "", "primary": { "id": "6444", "title": "Test Server", "sysid": "SYSID_1589213521", "type": "C__OBJTYPE__SERVER", "type_title": "Server" }, "description": "" } ] }Sorry for the long post, I hope the explanation of the problem is clear.
Thanks for the help.Best,
Mirko -
Hey @mirkomatonti
what versions of i-doit and the APIU add-on are you using?
I cannot reproduce this on i-doit 1.14.2 with the API add-on 1.11.1.Cheers,
Phil -
-
Hi @mirkomatonti
that's a bug which was fixed with the latest version of the API (1.11.1)
I recommend to update both to the actual versions.Cheers,
Phil -
@Philipp-Hörselmann
Great
Do you know where I can find the API(1.11.1)?Best,
Mirko -
Hi @mirkomatonti
do you use the i-doit open or i-doit pro?
If you are using the open version you can find the download in the download section of https://www.i-doit.org/download/
If you are using the pro version you can download the version from the customer portal with your customer login
Cheers,
Phil
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login