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-03-02 19:02:56

Oxfos
Member
Registered: 2021-03-02
Posts: 7

[RESOLVED] Adding/removing a contract from an item via the API

Hello,

How do I modify (with the API) the list of contracts associated with an item (not individual contracts properties but which contracts should be linked to that item)?

I manage to use the GLPI REST API to retrieve and modify data when the item can be directly identified with its id (much of which I understood going through this forum!).
The problem with the contracts of an item (e.g. a computer) is that they can be modified as individual items (i.e. a contract), independent from the item they are linked to but I do not find a way to e.g. change what contracts an item should have.
The reason is - I think - that, while there seems to exist an item called 'Contract_item' (you can even search its fields) which should/seems to 'contain' the list of contracts, it does not seem to exist independently from the item it is bound to.
So that, if I want to change the list of contracts e.g. a computer has (i.e. at the level of objects, not their properties (in that case I would work at the level of single contract)), I can't.

I couldn't find any hint in the forum (or where the GLPI REST API is described on GitHub).

Thank you in advance for any help/suggestion.

Last edited by Oxfos (2021-03-03 17:22:25)

Offline

#2 2021-03-03 17:21:12

Oxfos
Member
Registered: 2021-03-02
Posts: 7

Re: [RESOLVED] Adding/removing a contract from an item via the API

Dear all,

I have solved the problem (of changing the contracts connected to an item, e.g. a computer). Actually I wanted to change a contract in bulk (i.e. connected to many items at once) programmatically (via a loop).
I solved it not via the REST API but via the GUI: in the gui you can, per contract, check all connected items and, once you have filtered those which you want to change the contracts for, you can do that in bulk. Very quickly.
I did not know/think of this possibility because I am a programmer and I am asked to program (and use the REST API).
After some trying via the REST API I had to step back and remind to myself: The goal is solving the problem, not that it has to be solved with the REST API. It sounds easy but sometimes... it is not evident.
Thank you all who have checked.

N.B. Btw I still think it is not possible to do it programmatically. But if somebody comes up with a solution I would be very interested.

Last edited by Oxfos (2021-03-03 17:24:49)

Offline

Board footer

Powered by FluxBB