fields icon indicating copy to clipboard operation
fields copied to clipboard

API apirest.php : unable to retrieve custom field value

Open Galaellien opened this issue 5 years ago • 2 comments

Hello,

I am using GLPI 9.5.1, fields 1.11.0, PHP 7.4.7 I have created a block attached to the Project item type.

GET /Project/1// gives no output (no error message) GET // gives no output (no error message)

While those queries do give data with GLPI 9.3.4 + Fields 1.8.2

Is this a bug or a feature ?

Thank you

Galaellien avatar Aug 07 '20 06:08 Galaellien

Hello,

I am using GLPI 9.5.1, fields 1.11.0, PHP 7.4.7 I have created a block attached to the Project item type.

GET /Project/1// gives no output (no error message) GET // gives no output (no error message)

While those queries do give data with GLPI 9.3.4 + Fields 1.8.2

Is this a bug or a feature ?

Thank you

Hello,

Anything about this problem ? I have the same error, i can't put the 9.5 version of GLPI because we use scripts with the fields plugin.

bagahe avatar Sep 24 '20 13:09 bagahe

The fields added to the assets by plugin fields are not visible by the Rest API.

GLPI 10.0 Fields 1.14.0

Wolvverine avatar May 09 '22 18:05 Wolvverine

Not exactly, it could be a little bit tricky, but its possible. I use custom fields only for 'Computer' objects, so all examples below are about Computer.

  1. You should determine ID via API request for available search options like this - https://glpi/apirest.php/listSearchOptions/Computer
  2. Among all other option in the very bottom of the list you'll find IDs like "76665", you can recognize your wanted custom fields by their names
  3. Just use these IDs in requests like this - https://glpi/apirest.php/search/Computer?criteria[0][link]=AND&criteria[0][itemtype]=Computer&criteria[0][field]=76665&criteria[0][searchtype]=equals&criteria[0][value]=1&&forcedisplay[0]=76666

Hope it helps. Cheers

static302 avatar Dec 13 '22 15:12 static302

Thank you for the update.

Since my initial post, I have found a way to get the data I was looking for. I get the custom fileds values through a query like GET /PluginFieldsProject<custom_field_bloc_name>/

As far as I am concerned this topic can be closed.

Galaellien avatar Dec 14 '22 08:12 Galaellien

Can you, please, elaborate on your method via providing full example if possible, because I'm unable to find API endpoint like PluginFieldsProject in glpi :(

static302 avatar Dec 14 '22 09:12 static302

GLPI 9.5.11 Plugin fields 1.12.8

For object type Project, create a new block named "addon" through the plugin fields.

The content of this block can be queried with:

GET /PluginFieldsProjectaddon/

PluginFieldsProjectaddon comes from PluginFields

You can find the object name in the files generated in [...]/glpi/files/_plugins/fields/inc.

Is this any clearer?

Galaellien avatar Dec 15 '22 14:12 Galaellien

Yeah, found it. Looks really weird, but i see what you mean. Thank you.

static302 avatar Dec 15 '22 15:12 static302

Is this method still working on GLPI 10?

I fail to retrieve (via API) the value of a field I created for Computers.

C-Duv avatar Mar 19 '24 13:03 C-Duv

Method described in my post is still a thing. https://github.com/pluginsGLPI/fields/issues/398#issuecomment-1348808991

static302 avatar Mar 19 '24 14:03 static302