GetJSONResponse_POST
- Last UpdatedJan 05, 2022
- 1 minute read
Gets JSON response string from given DashBoard site, using HTTP POST method.
Syntax
Public static bool GetJSONResponse_POST (
string strURL,
string strQuery,
string payload,
out string strErrorMessage,
out string strJSONReturn
)
Parameters
|
strURL |
The dashboard URL to be queried with HTTP POST method. |
|
strQuery |
Query for HTTP POST method. |
|
payload |
Header body for POST method. |
|
strErrorMessage |
When this method returns, contains the error message, if fails otherwise, contains String.Empty. |
|
strJSONReturn |
When this method returns, contains the JSON response from DashBoard, if query gets response otherwise, contains String.Empty. |
Return value
true if success; otherwise, false.
Example
string strMessage = string.Empty;
string strJSON = string.Empty;
if (GetJSONResponse_POST(
"http://inhyzvms8r09:16000/",
"/api/v1/domain/searches/run",
"{\"criteria\":[{\"booleanOperator\":\"AND\",\"handle\":0,\"value\":\"J-9002A%\",\"secondValue\":null,\"valueOperator\":\"Like\",\"bracket\":\"None\",\"listOfValues\":false,\"itemIdentifierType\":\"Id\",\"label\":null},{\"itemIdentifierType\":\"Name\",\"value\":\"J-9002A%\",\"valueOperator\":\"Like\",\"booleanOperator\":\"OR\",\"bracket\":\"Close\"},{\"booleanOperator\":\"AND\",\"handle\":0,\"value\":\"LOGICAL (& OTHER PHYSICAL) OBJECT\",\"secondValue\":null,\"valueOperator\":\"Equals\",\"bracket\":\"None\",\"listOfValues\":false,\"itemIdentifierType\":\"ClassId\",\"label\":null}],\"paging\":{\"pageSize\":\"28000\",\"currentPage\":1},\"sorting\":{\"sortAscending\":true,\"sortBy\":\"Id\"},\"projection\":[{\"itemIdentifierType\":\"Id\"},{\"itemIdentifierType\":\"ClassId\"},{\"itemIdentifierType\":\"Revision\"},{\"attributeId\":\"Date\"}]}",
out strMessage, out strJSON))
{
Console.WriteLine("Returned JSON - {0}", strJSON);
}
else
{
Console.WriteLine("Failed - Error - {0}", strMessage);
}