Forum Discussion

MGB's avatar
MGB
Icon for Contributor rankContributor
3 months ago
Solved

Ansible or Curl example for importing policy variables via API

Hello All, I'm trying to import a list of variables in to Restorepoint via the API "/policies/variables/import" with ansible but as of now I have no luck. Does anyone have an example (can be with Cu...
  • MGB's avatar
    2 months ago

    Hello,

    Sending me back to the documentation is not very helpful since I asked for an example. In the meantime I have figured out the solution and want to share with the community.

    ansible.builtin.uri:
        url: https://{{ inventory_hostname }}/api/v2/policies/variables/import
        method: POST
        validate_certs: false
        body_format: form-multipart
        body: 
          file: 
            content: "{{ lookup('file','restorepoint_vars.csv') }}"
            filename: "restorepoint_vars.csv"
            Content-Type: text/csv
          overwrite: "true"
        headers:
    #      Content-Type: text/csv
          Authorization: "{{ ApiToken }}"

    This works for us,

    Regards,
    Michael