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 2024-10-09 23:18:13

ap1234
Member
Registered: 2024-10-09
Posts: 3

GLPI API post to /apirest.php/Line

GLPI API post to /apirest.php/Line

Trying to batch import lines via the api, but every time I do a POST to http://glpi/apirest.php/Line it responds back like I did a GET. Is there no POST option to /apirest.php/Line ? Am I doing it wrong? My post body has JSON formatted data, etc. I'm using the linestype_id, etc.



GLPI Version: 10.0.16
Linux: RHEL 9.4
NGINX
PHP 8.3.12

Last edited by ap1234 (2024-10-10 15:22:06)

Offline

#2 2024-10-10 16:13:10

ap1234
Member
Registered: 2024-10-09
Posts: 3

Re: GLPI API post to /apirest.php/Line

I've troubleshot this a lot with postman and curl and I believe I'm not formatting my array properly, but I'm unsure of exactly how it wants it.

["ERROR_BAD_ARRAY","input parameter must be an array of objects;

I've tried formatting my array with minimal fields returned via the GET and I've also tried a full blown entry with all the fields. I ran my JSON through linting and it all checks out. Anyone have any ideas?

Offline

#3 2024-10-10 18:08:12

ap1234
Member
Registered: 2024-10-09
Posts: 3

Re: GLPI API post to /apirest.php/Line

I was able to get it, in case anyone was wondering you just have to read the API documentation more thoroughly...

curl -X POST 'https://path/to/your/glpi/apirest.php/Line' \
-H 'Content-Type: application/json' \
-H "Session-Token: YOUR_SESSION_TOKEN" \
-H "App-Token: YOUR_APP_TOKEN" \
-d '{
  "input": {
    "name": "Test Line",
    "caller_num": "(123) 456-7890",
    "lineoperators_id": 1,
    "linetypes_id": 1,
    "states_id": 5,
    "locations_id": 0
  }
}'

Offline

Board footer

Powered by FluxBB