Ansible URI module and skip SSL validation I have a playbook which looks like
- name: CURL post example
  uri:
    url: &quot;https://dev-box.local/api/&quot;
    method: POST
    body: '{
           &quot;max_conns&quot;: 0,
           &quot;max_fails&quot;: 2,
           &quot;fail_timeout&quot;: &quot;3s&quot;
           }'
    body_format: json
    validate_certs: no
    return_content: yes
    force_basic_auth: yes
    headers:
      Content-Type: &quot;application/json&quot;


but during the execution I'm getting
 FAILED! =&gt; {&quot;changed&quot;: false, &quot;connection&quot;: &quot;close&quot;, &quot;content&quot;: &quot;{\&quot;status\&quot;:403,\&quot;message\&quot;:\&quot;Forbidden\&quot;}\n&quot;, &quot;content_length&quot;: &quot;37&quot;, &quot;content_type&quot;: &quot;application/json&quot;, &quot;date&quot;: &quot;Thu, 03 Dec 2020 21:03:13 GMT&quot;, &quot;elapsed&quot;: 0, &quot;json&quot;: {&quot;message&quot;: &quot;Forbidden&quot;, &quot;status&quot;: 403}, &quot;msg&quot;: &quot;Status code was 403 and not [200]: HTTP Error 403: Forbidden&quot;, 

when I will do the same call as the curl -k from the command line on the same box as ansible it works fine.
Any thoughts on that?
You seem to be passing force_basic_auth: yes but no user, nor password.
Example from the Ansible docs:
- name: Create a JIRA issue
  uri:
    url: https://your.jira.example.com/rest/api/2/issue/
    method: POST
    user: your_username
    password: your_pass
    body: &quot;{{ lookup('file','issue.json') }}&quot;
    force_basic_auth: yes
    status_code: 201
    body_format: json

The 403 is usually Basic Auth failing. If it's not, it could be the API server you're running requiring some sort of authentication.
If the curl -k command includes something like https://user:password@dev-box.local/api/ or the --user &lt;user:password&gt;, it should work. Or maybe it's using data from .netrc?
I hope this helps.