fields icon indicating copy to clipboard operation
fields copied to clipboard

update custom field via API

Open vquie opened this issue 5 years ago • 3 comments

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.

vquie avatar Aug 20 '20 13:08 vquie

anyone?

vquie avatar Oct 06 '20 07:10 vquie

Still none? There has to be someone who at least tried to update a field using the api.

vquie avatar Feb 03 '21 14:02 vquie

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.

redisded avatar Feb 23 '21 16:02 redisded

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 }

Pierre49300 avatar Dec 21 '22 14:12 Pierre49300

Hi, @Pierre49300 First of all, thanks for sharing. Does your field type is common text?

Anyone have success stories for updating dropdown field?

static302 avatar Jan 12 '23 14:01 static302

HI @static302, yes it's a common text, not dropdown field

Pierre49300 avatar Jan 12 '23 17:01 Pierre49300

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

quentinlegay avatar Aug 18 '23 13:08 quentinlegay

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.

vquie avatar Aug 18 '23 13:08 vquie