You're sure it's using POST?
Alternatively try supplying a yaml data structure for body and let
'body_format: json' create the json.

Can it be that the request requires additional http headers to be set?

On Thu, 20 Jul 2017 at 13:03, Megan Liu <[email protected]> wrote:

> 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";
>
>         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";,
>
>             "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";
>
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/65e27c8a-205e-4ea0-a37e-e8e69e68be3b%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/65e27c8a-205e-4ea0-a37e-e8e69e68be3b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Dick Visser
Sr. System & Network Engineer
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMdjhAwO_a_gZT1pc9EVFeb%3Drsr5Kb7UGSebgKTGzXyHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to