win_uri: fix body with one item in list (#49484)

pull/49827/head
Andrea Scarpino 6 years ago committed by Jordan Borean
parent a24cc8b235
commit 06099bd116

@ -0,0 +1,2 @@
bugfixes:
- win_uri - allow to send a JSON array with just one item into - https://github.com/ansible/ansible/issues/49483

@ -179,7 +179,7 @@ if ($user -and $password) {
}
if ($null -ne $body) {
if ($body -is [Hashtable]) {
if ($body -is [System.Collections.IDictionary] -or $body -is [System.Collections.IList]) {
$body_string = ConvertTo-Json -InputObject $body -Compress
} elseif ($body -isnot [String]) {
$body_string = $body.ToString()

@ -296,6 +296,29 @@
- json_as_dict.json.json == json_as_dict_value
- json_as_dict.status_code == 200
- name: send JSON body with 1 item in list
win_uri:
url: https://{{httpbin_host}}/post
method: POST
body:
- foo: bar
headers:
'Content-Type': 'text/json'
return_content: yes
register: json_as_oneitemlist
- name: set fact of expected json 1 item list
set_fact:
json_as_oneitemlist_value:
- foo: bar
- name: assert send JSON body with 1 item in list
assert:
that:
- not json_as_oneitemlist.changed
- json_as_oneitemlist.json.json == json_as_oneitemlist_value
- json_as_oneitemlist.status_code == 200
- name: get request with custom headers
win_uri:
url: https://{{httpbin_host}}/get

Loading…
Cancel
Save