You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2021-08-10 19:06:47

dhedges1
Member
Registered: 2021-08-09
Posts: 2

getting ERROR_BAD_ARRAY when trying to post via api

I can pull date with a get, but when trying to post anything back using the api, I keep getting the response of:

["ERROR_BAD_ARRAY","input parameter must be an array of objects; view documentation in your browser at https//glpi.mydomain.net/apirest.php/#ERROR_BAD_ARRAY"]

I've tried this, along with the exact syntax listed in the api docs...

curl -X PUT -H 'Context-Type: application/json' -H "Session-Token: my-session-token" -H 'App-Token: my-app-token' 'http//glpi.mydomain.net/apirest.php/Computer/5380' -d '{"input": {"comment": "test"}}'

I had also tried encapsulating the data portion like this as seen in another response: {"input": [{"comment": "test"}]}

no matter what I try, I seem to get the same error.

Offline

#2 2021-08-10 19:33:18

keepcool5283
Member
Registered: 2013-10-10
Posts: 158

Re: getting ERROR_BAD_ARRAY when trying to post via api

Hello,

Did you try on POSTMAN to test your command ?

In Postman if i type this : (PUT) https://server/apirest.php/Computer/69/?expand_drodpowns=false&range=0-200&order=desc&session_token=37lgkfkii67ff248kt34XXXXX
Body => Raw (JSON)

{"input":{"comment":"test"}}

it's working well


Apps Android GLPI Management : https://play.google.com/store/apps/deta … fr.dmn.app
Site Web : http://mdu-tech.fr/
GLPI 9.5.5 sur IIS 10 / PHP 8 / MySQL

Offline

#3 2021-08-10 21:34:16

dhedges1
Member
Registered: 2021-08-09
Posts: 2

Re: getting ERROR_BAD_ARRAY when trying to post via api

I'm not sure just what your getting at.
yes, I agree, it should work, but when posting agains GLPI, it does not.

Offline

#4 2021-08-11 10:09:34

keepcool5283
Member
Registered: 2013-10-10
Posts: 158

Re: getting ERROR_BAD_ARRAY when trying to post via api

POSTMAN is a tool where you can try your command (https://www.postman.com/)

When I check your command CURL I see that :  'Context-Type: application/json' but the documentation use this : 'Content-Type: application/json'
May be this part is wrong on your command.

Sorry but in my side I do only HTTP request


Apps Android GLPI Management : https://play.google.com/store/apps/deta … fr.dmn.app
Site Web : http://mdu-tech.fr/
GLPI 9.5.5 sur IIS 10 / PHP 8 / MySQL

Offline

#5 2021-08-12 08:07:18

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: getting ERROR_BAD_ARRAY when trying to post via api

Put is for updating data.
Use post to add .


Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9

Offline

Board footer

Powered by FluxBB