I have tried uri module in ansible, but I have still 401 authentication errors. In shell module when I am using curl all works. Can somebody please try to translate to uri code ?
- name: Get authentication token
uri:
url: https://myIPcontrol.com:8443/inc-rest/api/v1/login
method: POST
timeout: 30
validate_certs: no
headers:
Content-Type: application/x-www-form-urlencoded
Accept: application/json
body:
username: admin
password: mypsw
body_format: json
return_content: yes
register: authtoken
- name: Get authentication token
shell: "curl -k --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept:
application/json' -d 'username=admin&password=mypsw' -X POST
https://myIPcontrol.com:8443/inc-rest/api/v1/login"
register: authtoken