Reputation: 553
Sample curl request.
curl -X POST \
--data '"test connection"' \
-H 'Content-type: application/json' \
-H 'Authorization: Basic asdfasdf' \
dns.com/end
Now, I'd like to send exactly the same message using curl ansible playbook.
---
- name: "Send test"
hosts: localhost
tasks:
- name: Send test
uri:
url: dns.com/end
method: POST
src: '"test connection"'
body_format: json
headers:
Content-type: "application/json"
Authorization: "Basic asdfasdf"
I'm getting an error.
Upvotes: 0
Views: 1221
Reputation: 89
You have mentioned body format as json
and you are not passing any body to it.
You body.json file should contain something like this:
{
"name": "test connection"
}
and also you can mention status_code=201 for POST method.
Upvotes: 0
Reputation: 584
Just to add src
is used when you want to submit the data from a file.
Solution will look something like
tasks:
- name: Send test
uri:
url: dns.com/end
method: POST
body: "test connection"
headers:
Content-Type: "application/json"
Authorization: "Basic asdfasdf"
Upvotes: 0