update custom field via API
Hello,
I know this might have been asked several times but none of the solutions have worked for me so far.
I've got this block called customfield with a custom field called Cost Unit which I want to update using the REST API.
According to some advices I have already found I should PUT the data '{"input": { "costunitfield": "ABC" }}' to https://glpi/apirest.php/Computer/123
The response I always get is [{"123":true,"message":""}] with nothing updated in GLPi.
/apirest.php/listSearchOptions/computer gives me a map for the correct field with the id 76665 which I also tried to update with no luck.
/apirest.php/Computer/123 doesn't show this field at all.
Thanks in advance.
anyone?
Still none? There has to be someone who at least tried to update a field using the api.
Hi,
probably not the solution you want to read, but I update my custom fields in bash scripts by updating the database without problems since several month.
Hi, this ps1 code works for me :
$body='{"input": { "id":123 , "costunitfield": "ABC"}}'
$Parameters = @{ Method = "PUT" Uri = "https://your_glpi_url/apirest.php/Computer/" Headers = $headers Body = $body }
Hi, @Pierre49300 First of all, thanks for sharing. Does your field type is common text?
Anyone have success stories for updating dropdown field?
HI @static302, yes it's a common text, not dropdown field
Hi @vquie, can you give me the name of the block (+ label) of your custom field (name of the tab/category of the field) Thanks
Hi @vquie, can you give me the name of the block (+ label) of your custom field (name of the tab/category of the field) Thanks
Thanks for your response, but it has been years already. I am working for a different company now and this is not an issue for me anymore as I don't use this plugin anymore. I couldn't even answer it if I tried to. :-)
I am closing this.