Could not find any related online source to get the xml result, tried format filter but getting error
Need to return xml like this
<?xml version="1.0" encoding="UTF-8"?>
<BESAPI
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(names of it, ids of it, last report time of it) of bes computers whose(id of it=123)">
<Result>
<Tuple>
<Answer type="string">abc</Answer>
<Answer type="integer">123</Answer>
<Answer type="time">Mon, 14 Dec 2020 19:34:42 -0700</Answer>
</Tuple>
</Result>
<Evaluation>
<Time>0.160ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>
API function:
// GET api/Test/BigFixSelect
[HttpGet("BigFixSelect/{computerName}")]
public HttpResponseMessage TestBigFixSelect(string computerName)
{
try
{
string date = DateTime.UtcNow.ToString();
_logger.LogInformation("TestBigFixServer with '{0}' Initiated on '{1}'", computerName, date);
string XML = $"<BESAPI><Query><Result><Tuple><Answer type=string>{computerName}</Answer><Answer type=time>{date}</Answer></Tuple></Result></Query></BESAPI>";
return new HttpResponseMessage()
{
Content = new StringContent(XML, Encoding.UTF8, "application/xml")
};
}
catch (Exception ex)
{
string XML = $"<note><body>Bad Request</body></note>";
return new HttpResponseMessage()
{
Content = new StringContent(XML, Encoding.UTF8, "application/xml")
};
}
}
Current return result:
{
"version": {
...
},
"content": {
...
},
"statusCode": 200,
"reasonPhrase": "OK",
"headers": [],
"trailingHeaders": [],
"requestMessage": null,
"isSuccessStatusCode": true
}
None of the result has the return detail from my string content, I am new to this not sure if this is totally a wrong way of doing it or just missing out something.
I'm calling the action from PowerShell with :
Invoke-RestMethod -Headers $headers -Method GET -Uri $URL with $headers.Add('Accept','application/xml')