Hi guys,
i have a rest call that returns json how would i go about using that data in my web Parser..
Json data from REST call data is as below
{
"value": "NORMAL"
}
Url="http://SomePlace/rest/status/server"
RegExp="(?siU)"value": "(.*)".*"
i would like to know if this is possible or am i smoking my socks.
Could some pne please point me in the right direction.
Thanks in advance.
It is currently September 21st, 2024, 9:31 am
Web Parser and rest calls
-
- Posts: 7
- Joined: March 13th, 2014, 1:47 pm
-
- Developer
- Posts: 22749
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Web Parser and rest calls
Pretty much exactly like that...wezzone_007 wrote:Hi guys,
i have a rest call that returns json how would i go about using that data in my web Parser..
Json data from REST call data is as below
{
"value": "NORMAL"
}
Url="http://SomePlace/rest/status/server"
RegExp="(?siU)"value": "(.*)".*"
i would like to know if this is possible or am i smoking my socks.
Could some pne please point me in the right direction.
Thanks in advance.
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[MeasureServer]
Measure=Plugin
Plugin=WebParser
Url=http://SomePlace/rest/status/server
RegExp=(?siU)"value": "(.*)"
[MeasureRest1]
Measure=Plugin
Plugin=WebParser
Url=[MeasureServer]
StringIndex=1
[MeterRest1]
Meter=String
MeasureName=MeasureRest1
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
-
- Posts: 7
- Joined: March 13th, 2014, 1:47 pm
Re: Web Parser and rest calls
Hi jsmorley,
Thanks for the quick response.
i have tried your example and i am getting the following error
NOTE (18:54:21.114) WebParserGuide\WebParserGuide.ini: Refreshing skin
DBUG (18:54:21.114) WebParserGuide\WebParserGuide.ini: Reading file: C:\Users\wlucas\Documents\Rainmeter\Skins\WebParserGuide\WebParserGuide.ini
DBUG (18:54:21.114) : Reading file: C:\Users\wlucas\AppData\Roaming\Rainmeter\Rainmeter.ini
DBUG (18:54:21.114) WebParserGuide\WebParserGuide.ini - [MeasureServer]: WebParser: Fetching: http://Someserver:9090/rest/status/server
ERRO (18:54:21.114) WebParserGuide\WebParserGuide.ini - [MeasureServer]: WebParser: RegExp matching error (-1)
Are there setting on rain meter that could cause it to fail on my side. i am using your code exactly other than the correct url.
do you know of any public restful services that return json that you could use in an example, like a twitter feed. could it be that my server is returning the json weird. i looks like it finds the resource, the regular expression is what fails and that is my Achilles heel.
Thanks for the quick response.
i have tried your example and i am getting the following error
NOTE (18:54:21.114) WebParserGuide\WebParserGuide.ini: Refreshing skin
DBUG (18:54:21.114) WebParserGuide\WebParserGuide.ini: Reading file: C:\Users\wlucas\Documents\Rainmeter\Skins\WebParserGuide\WebParserGuide.ini
DBUG (18:54:21.114) : Reading file: C:\Users\wlucas\AppData\Roaming\Rainmeter\Rainmeter.ini
DBUG (18:54:21.114) WebParserGuide\WebParserGuide.ini - [MeasureServer]: WebParser: Fetching: http://Someserver:9090/rest/status/server
ERRO (18:54:21.114) WebParserGuide\WebParserGuide.ini - [MeasureServer]: WebParser: RegExp matching error (-1)
Are there setting on rain meter that could cause it to fail on my side. i am using your code exactly other than the correct url.
do you know of any public restful services that return json that you could use in an example, like a twitter feed. could it be that my server is returning the json weird. i looks like it finds the resource, the regular expression is what fails and that is my Achilles heel.
-
- Posts: 1740
- Joined: November 13th, 2012, 9:53 pm
Re: Web Parser and rest calls
the code is fine.
the problem is your initial post. you did not post the actual JSON response. you posted something you probably copied and pasted from a manual and is formatted to make it easier to read.
the problem is your initial post. you did not post the actual JSON response. you posted something you probably copied and pasted from a manual and is formatted to make it easier to read.
-
- Posts: 7
- Joined: March 13th, 2014, 1:47 pm
Re: Web Parser and rest calls
Hi moshi
i kind of figured it was that. i am using postman the chrome add on. i see you are right that which i pasted earlier was the pretty view of the json.
this is the Raw view, from postman
{"value":"NORMAL"}
i have modified the RegEx it now looks like this,
Url=http://10.0.1.124:7080/rest/status/server
RegExp=(?siU)"value":"(.*)"
even with the modified script i am getting "WebParser: RegExp matching error (-1)"
i kind of figured it was that. i am using postman the chrome add on. i see you are right that which i pasted earlier was the pretty view of the json.
this is the Raw view, from postman
{"value":"NORMAL"}
i have modified the RegEx it now looks like this,
Url=http://10.0.1.124:7080/rest/status/server
RegExp=(?siU)"value":"(.*)"
even with the modified script i am getting "WebParser: RegExp matching error (-1)"
-
- Posts: 7
- Joined: March 13th, 2014, 1:47 pm
Re: Web Parser and rest calls
i managed to resolve the issue.
turns out jsmorley code worked
i had an authentication problem, i found this by running fiddler. As soon as the widget updated i got a 401 error. My jboss server would return authentication failure html page. how i found this was by making my regEx "(?siU)<html>(.)</html>". Making what the widget pulled visible.
i then put the username and password in the URL as my server does support basic authentication.
thanks jsmorley and moshi you guys pointed me in the right direction
turns out jsmorley code worked
i had an authentication problem, i found this by running fiddler. As soon as the widget updated i got a 401 error. My jboss server would return authentication failure html page. how i found this was by making my regEx "(?siU)<html>(.)</html>". Making what the widget pulled visible.
i then put the username and password in the URL as my server does support basic authentication.
thanks jsmorley and moshi you guys pointed me in the right direction