# post data using ansible uri module always get error "bad request" but it works for Postman

**URL:** <https://forum.ansible.com/t/post-data-using-ansible-uri-module-always-get-error-bad-request-but-it-works-for-postman/25014>\
**Category:** Ansible Developer\
**Created:** [July 18, 2017, 3:48pm UTC](https://forum.ansible.com/t/post-data-using-ansible-uri-module-always-get-error-bad-request-but-it-works-for-postman/25014 "2017-07-18T15:48:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Megan\_Liu](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Megan\_Liu](https://forum.ansible.com/u/Megan_Liu)\
**Post date:** [July 18, 2017, 3:48pm UTC](https://forum.ansible.com/t/post-data-using-ansible-uri-module-always-get-error-bad-request-but-it-works-for-postman/25014/1 "2017-07-18T15:48:28Z")

</div>

HI

I really need help on Ansible URI module . I am not sure whether it is a bug or not.

I have the following playbook and when I run it and I always get error "bad request, “Parameter "ip\_address" is required”. But I have provided it when I sent the request. Please help me .

- hosts: localhost

strategy: debug

tasks:

- name: test post

uri:

url: “[https://80.75.107.12/rest/v1/networks/3135/deallocateip](https://80.75.107.12/rest/v1/networks/3135/deallocateip)”

user: “nixu”

method: POST

password: “XXX”

validate\_certs: no

force\_basic\_auth: yes

body: ‘{“ip\_address”: “192.168.180.2”}’

body\_format: json

register: result

- debug: var=result

fatal: [localhost]: FAILED! =\> {

“changed”: false,

“connection”: “close”,

“content”: “{"message": "Parameter \"ip\_address\" is required", "status": 400}”,

“content\_length”: “66”,

“content\_type”: “application/json”,

“date”: “Tue, 18 Jul 2017 15:46:24 GMT”,

“failed”: true,

“invocation”: {

“module\_args”: {

“attributes”: null,

“backup”: null,

“body”: “{‘ip\_address’:‘192.168.180.2’}”,

“body\_format”: “json”,

“content”: null,

“creates”: null,

“delimiter”: null,

“dest”: null,

“directory\_mode”: null,

“follow”: false,

“follow\_redirects”: “safe”,

“force”: false,

“force\_basic\_auth”: true,

“group”: null,

“headers”: {

“Authorization”: “Basic bml4dTpwYXNz”,

“Content-Type”: “application/json”

},

“http\_agent”: “ansible-httpget”,

“method”: “POST”,

“mode”: null,

“owner”: null,

“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“regexp”: null,

“remote\_src”: null,

“removes”: null,

“return\_content”: false,

“selevel”: null,

“serole”: null,

“setype”: null,

“seuser”: null,

“src”: null,

“status\_code”: [

200

],

“timeout”: 30,

“unsafe\_writes”: null,

“url”: “[https://80.75.107.12/rest/v1/networks/3135/deallocateip](https://80.75.107.12/rest/v1/networks/3135/deallocateip)”,

“url\_password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“url\_username”: “nixu”,

“use\_proxy”: true,

“user”: “nixu”,

“validate\_certs”: false

}

},

“json”: {

“message”: “Parameter "ip\_address" is required”,

“status”: 400

},

“msg”: “Status code was not [200]: HTTP Error 400: BAD REQUEST”,

“redirected”: false,

“server”: “nginx/1.10.1”,

“status”: 400,

“url”: “[https://80.75.107.12/rest/v1/networks/3135/deallocateip](https://80.75.107.12/rest/v1/networks/3135/deallocateip)”

}
