Post Json to API via Ansible


I want to make a POST request to an API endpoint via Ansible where some of the items inside the post data are dynamic, here is what I try and fail:

My body_content.json:

And here is my Ansible task:

Sadly this doesn’t work:

My ansible version is 1.9.1


You can’t use newlines like this in yaml. Try this instead (the “>” indicates that the next lines are to be concatenated):

But I find this much better:

Leave a Reply