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 2023-06-16 08:57:06

JAssfalg
Member
Registered: 2023-06-16
Posts: 8

How to add a manuallink in a computer item in a json file ?

Hello,

i would like to add a manuallink to the computer item but i doesn't work.
json_data = {
            'input': {
                'name': item["deviceAssetId"],
                'serial': item["deviceSerialNumber"],
                'manufacturers_id': glpi_manufacturers_id,
                'computermodels_id': glpi_computermodels_id,
                'locations_id': glpi_standort_id,
                'states_id': glpi_geraetestatus_id,
                'operatingsystems_id': 1,
                "manuallink": 'link',
                'comment': ''
            }
        }

        # Make the POST request to insert the computer
        response = requests.post(self.link_server + "Computer" + '/', headers=self.headers, json=json_data)
        data = response.json()

How can i add or update a link to the item. Can you please give me a kicking off ?

Thanks a lot for your help.
lg Joachim

Offline

#2 2023-06-16 16:59:31

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: How to add a manuallink in a computer item in a json file ?

There is no such field as "manuallink" for computers. The manual link is a separate item.
Itemtype: "ManualLink"
Main fields: name, url, itemtype, items_id

Set the itemtype field to "Computer" and items_id to the ID of the computer you want it linked to.


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

#3 2023-06-21 16:30:59

JAssfalg
Member
Registered: 2023-06-16
Posts: 8

Re: How to add a manuallink in a computer item in a json file ?

Thanks for the rely. Now it works.

json_data = {
            'input': {
                'name': 'Google Admin',
                'itemtype': 'Computer',
                'items_id': id,
                'url': 'Link + item['deviceId'] ,
                'comment': ''
            }
        }


        response = requests.post(self.link_server + 'ManualLink/', headers=self.headers, json=json_data)
        data = response.json()

Offline

Board footer

Powered by FluxBB