I am trying to create a Meraki group policy via API using Ansible. When running the ansible-playbook, I get "New group policies must have a name" error message. Name is added in the json files. Can you please check the json and playbook files and help and sorting this issue. Many Thanks.
Playbook.yml
- name: Group Policy via API
hosts: localhost
gather_facts: no
tasks:
- name: Deploy Group Policy
uri:
url: https://api.meraki.com/api/v1/networks/xxxxxxxxxxxxxxxxxxx/groupPolicies
method: POST
return_content: yes
headers:
X-Cisco-Meraki-API-Key:xxxxxxxxxxxxxxxxxxxxxxxxxxx
body_format: json
body: "{{ lookup('ansible.builtin.file','create_body_4.json') | to_json }}"
create_body.json { "name": "test01" }
I have also tried the RequestBody(JSON) from the Meraki example (https://developer.cisco.com/meraki/api-v1/#!create-network-group-policy) but still get the same error message. It seems like "create_body.json" file is not in correct format hence "name" is not parsed properly.
Many thanks.
Issue Resolved: Removed | "to_json" from body as file was already in json Correct format is body: "{{ lookup('ansible.builtin.file','create_body_4.json')