Hi,
Following JSON:
{
"value": [
{
"weekStartDate": "2018-11-05T00:00:00+01:00",
"numberOfTrainingEvents": 1,
"weekNumber": 45,
"yearWeekFormat": "2018-45"
},
{
"weekStartDate": "2018-11-12T00:00:00+01:00",
"numberOfTrainingEvents": 0,
"weekNumber": 46,
"yearWeekFormat": "2018-46"
}
],
"Count": 2
}
With following JSONPath Expression
$.value[?(@.weekNumber)]
Gives no errors in your suggested validators/ converters, but the Site24x7 monitor I'm trying to create using this JSONPath Expression fails to evaluate every time.
- jsonpath.herokuapp.com/
- www.site24x7.com/tools/json-path-evaluator.html
Why?
Hello,
The JSONPath expression appears to be valid. Please open a ticket with support so that we can see the actual output received from the server for your REST API monitor and identify the problem.
Regards,
Kurian
Hi Kurian
We've already done that. Sent email with details to mailto:support@site24x7.com%2Cticket ID 638566.
That was me ^
Would also like to add that:
- Your forum system does not handle URLs well
- Your forum system does not allow .eu users, had to create a seperate user just to post to your forums.
- Your forum system does not handle sessions very well. I was logged in when posting the comment above this one, still got marked as guest user.
Our support staff will analyze the monitor and get back to you through the support channel.
Thank you.
Just to post an update on this issue, we basically found out that PowerShell 5.1 "Invoke-RestMethod" adds values to the respond. So the root levels "value" and "count" from first post, does not actually get returned by the rest API, and thus RESTPath valuation fails.
Workaround is to put parantheses around "Invoke-RestMethod" before "ConvertTo-Json" to get the actual respons from a REST api. So
- (Invoke-RestMethod -Uri $Uri -Headers $Header) | ConvertTo-Json
Which gives:
{
"weekStartDate": "2018-11-05T00:00:00+01:00",
"numberOfTrainingEvents": 1,
"weekNumber": 45,
"yearWeekFormat": "2018-45"
},
{
"weekStartDate": "2018-11-12T00:00:00+01:00",
"numberOfTrainingEvents": 0,
"weekNumber": 46,
"yearWeekFormat": "2018-46"
}
Not the following
- Invoke-RestMethod -Uri $Uri -Headers $Header | ConvertTo-Json
Which gives
{
"value": [
{
"weekStartDate": "2018-11-05T00:00:00+01:00",
"numberOfTrainingEvents": 1,
"weekNumber": 45,
"yearWeekFormat": "2018-45"
},
{
"weekStartDate": "2018-11-12T00:00:00+01:00",
"numberOfTrainingEvents": 0,
"weekNumber": 46,
"yearWeekFormat": "2018-46"
}
],
"Count": 2
}
Thanks to Site24x7 support team that pointed this out.