REST API via Ansible

Hey everyone - I’m trying to use Ansible to build a pipeline for deploying our policy files and I’m having some issues when trying to use API endpoint for updating/loading policies.

I continue to get 422 errors and I can’t seem to figure out how to format the body of my request. Has anyone done encountered this before? Anyone have any examples?

Thanks!

Hi Mitch,
422 is usually a mis-formatted YML. I think you just have to make sure that there is no data formatting applied to the body of the request for it to be fine. You can take a look at our Python API code here if you need some inspiration from code and here are some super-simple example policies.

Srdjan

1 Like

there is an api collection in insomnia:

Insomnia allows for code generation to various environments which would format as needed for you.

1 Like

Hi Srdjan,

Thanks for the insight. Formatting was the issue :slight_smile:

I defaulted to powershell to figure out more since I’m not as familiar with Ansible and it seems as though powershell’s file input cmdlet (Get-Content) loads a file line by line as a collection and not a single item. After adding the -raw switch everything went perfect!

I’m hoping that Ansible will be a similar issue. Thanks!

Thanks for your help

Awesome! Glad I could help!

Hi @Mitch,

I ran into the same issue when creating a powershell module for Conjur.
If you are interested in using this module is can be found here: https://github.com/cyberark/conjur-api-powershell

Regards,
Andrew

1 Like