Answers: <p>You seem to be passing <code>force_basic_auth: yes</code> but no <code>user</code>, nor <code>password</code>.</p>
  <p>Example from the Ansible docs:</p>
  <pre><code>- 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
  </code></pre>
  <p>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.</p>
  <p>If the <code>curl -k</code> command includes something like <code>https://user:password@dev-box.local/api/</code> or the <code>--user &lt;user:password&gt;</code>, it should work. Or maybe it's using data from <code>.netrc</code>?</p>
  <p>I hope this helps.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-12-04T16:31:00.490Z
Answers: yeah - that + adding `become: true` fixed that
Answers: JackTheKnife
Answers: CC BY-SA 4.0
Answers: 2020-12-04T15:32:30.880Z
Answers: 2020-12-04T15:32:30.880Z
Answers: migueldavid
Body: <p>I have a playbook which looks like</p>
  <pre><code>- 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;
  
  </code></pre>
  <p>but during the execution I'm getting</p>
  <pre><code> 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;, 
  </code></pre>
  <p>when I will do the same call as the <code>curl -k</code> from the command line on the same box as ansible it works fine.</p>
  <p>Any thoughts on that?</p>
  
Tags: <ansible>
Title: Ansible URI module and skip SSL validation
UserDisplayName: JackTheKnife
ThreadText: # Ansible URI module and skip SSL validation
  
  (Asked by: username_0 on 2020-12-03)
  
  I have a playbook which looks like
  
  ```
  - name: CURL post example
    uri:
      url: "https://dev-box.local/api/"
      method: POST
      body: '{
             "max_conns": 0,
             "max_fails": 2,
             "fail_timeout": "3s"
             }'
      body_format: json
      validate_certs: no
      return_content: yes
      force_basic_auth: yes
      headers:
        Content-Type: "application/json"
  
  ```
  
  but during the execution I'm getting
  
  ```
   FAILED! => {"changed": false, "connection": "close", "content": "{\"status\":403,\"message\":\"Forbidden\"}\n", "content_length": "37", "content_type": "application/json", "date": "Thu, 03 Dec 2020 21:03:13 GMT", "elapsed": 0, "json": {"message": "Forbidden", "status": 403}, "msg": "Status code was 403 and not [200]: HTTP Error 403: Forbidden", 
  
  ```
  
  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?
  
  **Tags:** ansible
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-04. Score: 1 | Accepted answer
  
  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: "{{ lookup('file','issue.json') }}"
      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 <user:password>`, it should work. Or maybe it's using data from `.netrc`?
  
  I hope this helps.
  
  > **Comments:**
  > **username_0**: yeah - that + adding `become: true` fixed that  
  
  ---
  
  