You are not logged in.
So I'm having what seems to be a common issue. Updating entries in other databases connected to the main.
Read this - Use:
curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token xxxx" \
-H "App-Token xxxx" \
-d '{"input": {"itemtype": "Problem", "items_id": ## problem_id##, "content": "my note content"}}' \
'http://path/to/glpi/apirest.php/Notepad/'
I changed the "itemtype" to computer, added the correct computer ID and now I get a return that the note is incrementing but no note in the associated computer item.
id message
-- -------
7745
Can someone help with the correct syntax? Is something missing?
Last edited by evobe (2023-10-22 16:25:06)
Offline
to update any field using API you should use PUT methode instead of POST method.
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
It sounds like they are trying to add a new note rather than update an existing one since they dont have an ID in the URL.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Hi,
Exactly, I wanted to update a note - but I can understand because it does say 'update' Anyway, it's solved!
The return message I was getting back was actually correct, I just had to wait for the system to update.
Invoke-RestMethod -uri "$PathtoGlpi/Notepad/" -Method Post -headers $sessionheaders -Body $jsonupdate
json body - not sure if the user is required or not since when checking the profile I'm the one logged in
$updaterequest = @{input=@{
'itemtype'="Computer"; 'items_id'="$($id)"; 'content' = "now this is a note added to GLPI from PS by me"; 'users_id' = "xxxx"
}
}
Offline
not sure if the user is required or not since when checking the profile I'm the one logged in
It isn't. In fact, it has no effect since "users_id" is always replaced with the current user ID.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline