Contains tips for configurators working with Aware IM
#46511 by PointsWell
Fri Mar 09, 2018 1:32 am
This isn't a tip or a trick, it's just the first REST API call that I have made work.

This is a very simple API to get the weather conditions from

To use it you will need to register and obtain a key.
Store the Key in SystemsSettings.KeyWeather and store it as '&APPIDxxxxxxxxxxx', where x is the key you got from open

The Service BO is Weather.
The Parameters for Weather are loaded into a temporary BO called tWeather with one attribute:
tWeather.parameters - this collates the elements that come after the ? in the REST Call (i.e. 'q='+City.Name+','+City.Country+SystemSettings.KeyMap)

There is one actual BO, City:
and then a bunch of fields to store the weather in.

The response is JSON and is loaded into:
WeatherResponse which contains a number of OB attributes to:

To use:
Launch into the home page
Create a few City objects from the limited number of Countries available.
If you don't put a real city in then the process will fail (gracelessly - I haven't put in error checking)
Then from the grid press the Get Weather button
The City BO will then be updated with some weather details.

Its not super complicated but it may help someone work through the various steps.

This was built with AIM v 8.1 Build 2441
There is still an error appearing in the console, but it doesn't appear to be affecting the API
Simple Weather Model
(40.54 KiB) Downloaded 352 times
#46532 by Jaymer
Sun Mar 11, 2018 1:11 am
(edited to change "XML" to "JSON")
there's 2 fields... one is "main" (ie. the main weather string returned) and another "string 20" that depending on the weather conditions, those attributes are not long enough and the request craps out with a error - about truncation.
Atlanta happened to "lightly drizzling rain" or somesuch and it was too long.

How did you figure out you needed to have child related tables to hold the JSON data?
I'd like to talk to the person who told you, cause I'd buy you a drink at the conference if you figured it out yourself.
I was able to add another file for Wind, as well as another main field in the top level.
No issues.

But I get a fatal error doing the same type of thing on a totally different API.
I can get 2 "top level" fields, and then the all the rest of the data is 1 level down, and it throws an error.
I can see the JSON is coming back, and the trace points to an error in the JSON parsing, so I don't really think its my fault, but 2 hours down the drain nevertheless.
Last edited by Jaymer on Sun Mar 11, 2018 7:13 pm, edited 3 times in total.
#46533 by PointsWell
Sun Mar 11, 2018 1:21 am
Haha it was a trial and error - the response is JSON and not XML.

Have a look at ... 30761fae22

I worked out that everything that follows [ is a child BO - I only used the current forecast in my test, but the weekly forecast would obviously bring back multiple values which was the giveaway that it is a parent child relationship.

The truncation error is just the field being too short, I was lucky that the weather was always simple when I was testing :D

I then tried to use a more relevant API for my needs that was XML based but the response was too clever (or a horrible basket case and was too hard to decipher).

I’m going to try and find a more simple XML example to test.
#46536 by Jaymer
Sun Mar 11, 2018 7:12 pm
Since I'm having probs with a JSON reply on my SchoolDigger API, and seeing this was an easy way to get XML in the only working REST example we have, I thought I'd try XML and see if it worked straightaway.

I added &mode=xml to the parm string, to get back XML.
Changed the service to say the result was XML (before changing from JSON) threw a NULL error on the reply.
When Getting Weather for the 1st try, I got an error that it couldn't find BO "current"

the reply is:
Code: Select all<current>
<city id="4180439" name="Atlanta">...</city>
<temperature value="287.06" min="286.15" max="288.15" unit="kelvin"/>
<humidity value="100" unit="%"/>
<pressure value="1011" unit="hPa"/>
<clouds value="90" name="overcast clouds"/>
<visibility value="16093"/>
<precipitation mode="no"/>
<weather number="804" value="overcast clouds" icon="04d"/>
<lastupdate value="2018-03-11T18:40:00"/>

1) tag "current" is the topmost tag, and when trying to add an Attribute named "current", says its reserved.
2) makes me wonder if thats what the NAME MAPPING link is for?
3) too bad the NAME MAPPING link does nothing when I click on it
#46537 by PointsWell
Mon Mar 12, 2018 12:39 am
So from what I can make out it seems that AIM is trying to insert the XML into a BO called current, ignoring the fact that you have renamed the receiving object to some other name than current.

This is very similar to the issue I was having with the complex/ugly XML example I was working with.

Have tried with a BO called 'current' but it still doesn't like that so I think it may be a bug.
#46554 by PointsWell
Mon Mar 12, 2018 11:06 pm
Jaymer wrote:When Getting Weather for the 1st try, I got an error that it couldn't find BO "current"

Have heard back from Vlad. This is an issue that has been addressed

Who is online

Users browsing this forum: No registered users and 3 guests