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 2018-12-07 17:27:47

ernieek
Member
Registered: 2018-12-07
Posts: 1

Use API to update field but it's not updating but adding

hello,


I use the following powershell code:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Content-Type','Application/Json')
$headers.Add('Session-Token', $GLPI_Session)
$headers.Add('App-Token', $GLPI_Apikey)

$json = '{"input": { "id":71 , "comment": "test"}}'
$result = Invoke-WebRequest -Uri ($GLPI_ApiUrl+'/Computer') -Body $json -ContentType "application/json" -Headers $headers -Method POST


What I will do is trying to update the comment field, and after if this is working the purch date, warranty expiration.

But it's now not updating the computer with id 71, it is adding a new compiter with an other id.....


Can someone help me how to update otherfiels then comment and on the right computer.

Kind regards Erwin

Offline

#2 Yesterday 23:54:47

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,282

Re: Use API to update field but it's not updating but adding

to update use PUT method, ( not POST)


PS : i move to APIREST Section


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.3.3  en test (ubuntu 18.04 mariadb 10.2.4)

Offline

Board footer

Powered by FluxBB