I am trying to send a JSON payload using uri module through body parameter. The variables {{ network-name }} and and {{ IP1 }} are imported from config.yml.
I have
defined body in vars. The json code which I am trying to print is getting created properly using (debug: var={{ body | to_json}}). But, the output which I am redirecting to the dest file is showing errors. What could be the reason that the JSON payload is not getting sent at the destination url.
Here's the ansible playbook:
---
- hosts: localhost
connection: local
vars_files:
- config.yml
vars:
body:
id: 100
network:
name: "{{ network-name }}"
net_list:
- link_id: 1
- type: abc
vlan: "10"
profile: switch
tasks:
- debug: var="{{ body | to_json }}"
- name: Run POST command
uri:
url: "https://{{ IP1 }}/url/to/dest"
method: POST
body: "{{ body | to_json
}}"
user: "abc"
password: "xyz"
HEADER_Content-Type:
"application/json"
force_basic_auth: yes
return_content: yes
dest: /url/to/dest/file