mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
win_uri: fix body with one item in list (#49484)
This commit is contained in:
parent
a24cc8b235
commit
06099bd116
3 changed files with 26 additions and 1 deletions
2
changelogs/fragments/win_uri-oneitem-list.yaml
Normal file
2
changelogs/fragments/win_uri-oneitem-list.yaml
Normal file
|
@ -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 ($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
|
$body_string = ConvertTo-Json -InputObject $body -Compress
|
||||||
} elseif ($body -isnot [String]) {
|
} elseif ($body -isnot [String]) {
|
||||||
$body_string = $body.ToString()
|
$body_string = $body.ToString()
|
||||||
|
|
|
@ -296,6 +296,29 @@
|
||||||
- json_as_dict.json.json == json_as_dict_value
|
- json_as_dict.json.json == json_as_dict_value
|
||||||
- json_as_dict.status_code == 200
|
- 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
|
- name: get request with custom headers
|
||||||
win_uri:
|
win_uri:
|
||||||
url: https://{{httpbin_host}}/get
|
url: https://{{httpbin_host}}/get
|
||||||
|
|
Loading…
Reference in a new issue