Solved
How to post json array to an external REST service?
I write a TWX script to send http post to an external REST service as below.
var headers = {
"content-type": "application/json;charset=utf-8"
};
var queryParams = [
{
"ColumnName": "TaskGroupID",
"Sign": "=",
"Value": "c0c3f361-b8f0-4d98-8ab3-f507179beb79"
},
{
"ColumnName": "TaskItemID",
"Sign": "=",
"Value": "'d24ba69e-82be-49d4-abbe-3821c371bae5','10bc58c0-0583-4cf4-b7fb-98ad5e99eafa','45c74c31-dace-48c4-9784-5157b001090b','b41ce652-c325-4e03-8dfe-d2693ced01d4'"
}
];
var params = {
headers: headers /* JSON */,
ignoreSSLErrors: true /* BOOLEAN */,
url: "http://localhost:8010/api/Report/GetTaskItemReport?isCurrentReport=false" /* STRING */,
content: queryParams /* JSON */,
timeout: 60000 /* NUMBER */,
password: me.Password /* STRING */,
username: me.UserName /* STRING */
};
var result = Resources["ContentLoaderFunctions"].PostJSON(params);
But the REST server receive the content like
{"array":[
{
"ColumnName": "TaskGroupID",
"Sign": "=",
"Value": "c0c3f361-b8f0-4d98-8ab3-f507179beb79"
},
{
"ColumnName": "TaskItemID",
"Sign": "=",
"Value": "'d24ba69e-82be-49d4-abbe-3821c371bae5','10bc58c0-0583-4cf4-b7fb-98ad5e99eafa','45c74c31-dace-48c4-9784-5157b001090b','b41ce652-c325-4e03-8dfe-d2693ced01d4'"
}
]}
The PostJSON api send my json array as a json object with key 'array'. That make the REST server no working properly.

