Unable to process the JSON request in POST method

28 views
Skip to first unread message

Shyam

unread,
Sep 28, 2018, 2:20:42 PM9/28/18
to Ansible Project
Hi,

Unable process the JSON request in POST method can any one help.

---
- hosts: windows

  remote_user: user...@domain.com

  tasks:
 
  - name: POST a body to an endpoint

    win_uri:

      
      method: post
     
      user: us...@domain.com

      password: xxxxxxxxxxxxxxxxxxxxx

      force_basic_auth: yes

      body:  "{{ lookup('file','test.json') }}"

      body_format: json

      content_type: "application/json"

      return_content: yes


 
      
      Getting the following error: 

                  fatal: [server_hostname]: FAILED! => {"base_response":  { "CharcterSet": "ISO-8859-1", "ContentEncoding": 
                 "Status_description" : "No Content",
                   "Method": "POST"
                     "msg": "status  code of request '204' is not in list of valid status codes 204"

Can any one help ?

Kuldip Madnani

unread,
Sep 28, 2018, 2:37:57 PM9/28/18
to Ansible Project
Add this and try:
headers:
      Content-Type: "application/json"

Shyam

unread,
Sep 28, 2018, 2:58:52 PM9/28/18
to Ansible Project
Hi Kuladip,

Thanks for your reply. I have tried the option still getting the same error.  Any other suggestion please ?

Kuldip Madnani

unread,
Sep 28, 2018, 3:04:14 PM9/28/18
to Ansible Project

Kuldip Madnani

unread,
Sep 28, 2018, 3:07:20 PM9/28/18
to Ansible Project
Based on the error "No Content", i guess the file test.json contents are not readable, can you put the file contents as a json string in the body and see if it works, at least that will help you narrow down the problem.


On Friday, September 28, 2018 at 1:58:52 PM UTC-5, Shyam wrote:
Reply all
Reply to author
Forward
0 new messages