Go to All Forums

JSONPath Evaluation: Can't get REST monitor to report as up

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? 

Reply 1
Replies (5)

Re: JSONPath Evaluation: Can't get REST monitor to report as up

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

Reply 0

Re: Re: JSONPath Evaluation: Can't get REST monitor to report as up

Hi Kurian

We've already done that. Sent email with details to mailto:support@site24x7.com%2Cticket ID 638566.


Re: Re: Re: JSONPath Evaluation: Can't get REST monitor to report as up

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.
Reply 0

Re: Re: Re: JSONPath Evaluation: Can't get REST monitor to report as up

Our support staff will analyze the monitor and get back to you through the support channel.

Thank you.

Reply 0

Re: Re: Re: Re: JSONPath Evaluation: Can't get REST monitor to report as up

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.

Reply 1