I use PowerShell to send a POST request to the REST API . The request body is as follows:
{ "title": "game result", "attachments": [ { "image_url": "http://contoso/", "title": "good work!" }, { "fields": [ { "title":"score", "value":"100" }, { "title":"bonus", "value":"50" } ] } ] }
Now the following PowerShell script generates the wrong output:
$fields = @(@{title='score'; value='100'},@{title='bonus'; value='10'}) $fieldsWrap = @{fields=$fields}
Line 3 (if not commented out) produces the correct output, however line 7 creates:
{ "attachments": [ { "image_url": "http://contoso", "title": "good work!" }, { "fields": "System.Collections.Hashtable System.Collections.Hashtable" } ], "title": "game result"
}
It obviously HashTable type name HashTable , which is the default implementation of ToString() , which I assume. How to get the right result?
Roelf source share