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 Curl or another language) about the right syntax?

Regards,

Michael

  • 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

4 Replies

  • MGB's avatar
    MGB
    Icon for Contributor rankContributor

    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

    • SaraLeslieAdmin's avatar
      SaraLeslieAdmin
      Icon for Community Manager rankCommunity Manager

      Thank you for sharing this example MGB , I will also share this feedback with the team. 

      Best, Sara 

  • Hello Michael, 

    The team suggests you refer to this section of the API documentation. It should help you when trying to import the policy variables. Please let us know if we can be of further assistance. 

    Thank you, 

    Jude

    (In case the above link does not work for you, here is the full URL: https://docs.sciencelogic.com/restorepoint/api/5-6/api.html#operation/import_policy_variables)

  • Hello MGB I have reached out to the Restorepoint team to help answer this question. Thanks for posting!