Using the API to populate custom fields

support-info
support-info Member Posts: 9
edited December 2023 in Scripts

Hello, I was not able to find much on the subject so I'm posting here

I'm currently trying to populate a custom field on my agent using the Atera API
The field is named "Waranty coverage" it's a date field that will be containing the Waranty end date of the machine (I'm pulling the Waranty data from the Dell API).

From the API doc website (https://app.atera.com/apidocs#/) I'm able to get the current value of the field using this endpoint /api/v3/customvalues/agentfield/{agentId}/{fieldName}

Which give me the following result:

However I was not able to find what I'm supposed to put into the body of the request to update the value when using the endpoint with the PUT method

The only hint given by the documentation is this :

I've try everything I could think of and only got errors

I hope you guys will be able to help me with this
Thank you in advance

Tagged:

Comments

  • kim
    kim Member Posts: 113 ✭✭✭

    Hi @support-info! I haven’t tried this yet, but is this something that the Atera AI could pull for you?

  • nina
    nina Internal Posts: 428 ✭✭✭✭✭

    Hi @support-info - I have created a Support Ticket for you, ticket #420040.

  • support-info
    support-info Member Posts: 9
  • support-info
    support-info Member Posts: 9

    Thank you for your help, I will post the final script here if I can make it work

    BTW this could also be a nice additionnal feature for Atera to be able to pull the waranty information of the machine, since we are almost all using mainly Dell, Lenovo and HP devices, this would be a great asset managment feature

  • support-info
    support-info Member Posts: 9

    I was finaly able to update the custom field
    I was using the wrong date format …
    The correct date format was "yyyy-MM-dd"

    This bellow work:


    Thank you for your help

  • nina
    nina Internal Posts: 428 ✭✭✭✭✭
  • anton
    anton Member Posts: 15

    I'm curious to know if you've got a working script? We're also using Dell.

    Would be nice to ditch the cost of ScalePad..

  • support-info
    support-info Member Posts: 9

    Hey @anton
    I got a working script, I will try to clean it up a bit and upload it here asap
    I will also give some instruction on how to use it but it's prettry straight forward

  • support-info
    support-info Member Posts: 9

    Here is the script I have made @anton

    Here are the script requierments:
    1. An Atera API key (You can generate one here:https://app.atera.com/new/admin/api)
    2. Two Atera custom agent fields (You can create them here: https://app.atera.com/new/admin/dynamicfields)
    3. An Access to the Dell Api (Dell Warranty API Version) (you can get that here: https://techdirect.dell.com/Portal/ApplyForAPIKeyWizard.aspx )

    The script need no external module, it mainly use Invoke-webrequest.
    It does not need admin permission to run.
    All the script parametters can be set at the begining of the script (line 9 to 14)

    It perform the following actions:
    1. Get all the agent and export them to a csv file named : AteraAgentFullRawExport.csv
    2. Get the Warranty for all the agent and export the list to a csv file named: AteraCleanWithWaranty_updateList.csv
    3. Update all the Warranty and purchase date field on Atera
    4. Export all the agent that were updated without issue

    The custom fields look like this (sorry my Atera is in french)




    How to run the script:
    1. Unzip the script
    2. Set the requiered parametters (line 9 to 14)
    3. Put the script in a folder where you have the permission to create file (other wise the script will not be able to generate the csv reports)
    4. Run and wait

    If you need any help feel free to tag me here, I will be happy to help
    this code not perfect, I'm far from a Powershell export and I will be happy to get any feed back on it !

    One more thing: sometimes the dell laptop have multiple warranty plan for the device.
    My script only pick the waranty with the furthest expiration date.

  • anton
    anton Member Posts: 15

    Awesome! Thank you @support-info! My knowledge with powershell is limited but im super grateful for you instructions. Looks like I can figure this out :)

  • JackalopeHunter
    JackalopeHunter Member Posts: 4

    I followed the instructions but was getting an error because of the UTF8bom format and changed it to UTF8. The script ran fine but the custom fields are not populating.

  • anton
    anton Member Posts: 15

    If you havent tried already- then have a go with Powershell 7.