I’m trying to use the URI module with a query string that uses JSON as the value. I am using single quotes for the URI module param and double quotes for the JSON. However, the string is being used in the module as double quoted and the double quotes from the module param are being escaped. So the endpoint does not see it as valid JSON. Has anyone else ran into this issue?
ansible.builtin.uri:
url: ‘{{ base }}/api/v1/assets?_limit=100&_offset=0&_filters=[{“id”:“name”,“includeValues”:[“{{ inventory_hostname }}”],“excludeValues”:}]&with_count=true&order=asc&orderColumns=name&showInactive=false’
method: GET
This may not work (I don’t recall an API that accepts JSON), but have you considered defining the JSON as a YAML variable and then converting it to JSON? Something like:
I figured out my issue. It appears I had an extra double quote in the JSON. My Network team couldn’t get a firewall rule to work, so I was working on a system without an IDE and my old eyes missed that. The escapes did work once I took out the extra double quote.