Tagged: , , , ,

Viewing 0 reply threads
  • Author
    Posts
    • #12581

      To add assets in bulk, it is necessary to use the API and curl to make the requests, and create a file with the extension SH that will be the script that will execute all the requests.

      First we will create the assets.sh file and add the following line

      curl -X POST https://pegasusID.peginstances.com/api/assets -H “Authenticate: token” -H “Content-Type: application/json” -d ‘{“first_name”: “myName”, “last_name”: “MyLastName”, “type”: “driver”, “groups”: [ID,..,…]}’ >> assets.json

      Make sure to replace with your site, token and asset information.

      Example
      assets
      When you add all the necessary lines, you should run the SH file. To run it you can research on the Internet how to do it according to the platform you use.

      When this is finished, a JSON file will be created (in the same location where the script is located) with the response of the request made, there you will be able to obtain the ID of the asset that was created, you will need it to register the ibuttons.

      Now we continue with the ibuttons, you must create a file ibuttons.sh and add the following request

      curl -X POST https://pegasusID.peginstances.com/api/ibuttons -H “Authenticate: token” -H “Content-type: application/json” -d ‘{“id”: “ibuttonID”, “entity”: AssetID}’ >> ibuttons.json

      Like the previous file, you must replace with the corresponding information.

      Example
      ibuttons

      Once you have the ibuttons script ready, you must execute it 2 times, the first time is to register the ibutton and the second time is to associate it with the asset, with this you finish the creation of Assets with ibutton.
      In case you only need to add the assets you can omit the part of the ibuttons.

      Note: Wait for the script to finish before running another one.

Viewing 0 reply threads
  • You must be logged in to reply to this topic.