If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#53098 by kklosson
Sun Feb 09, 2020 7:30 pm
AwareIM 8.4. Trying to hookup the zipcode radius API from zipcodeapi.com.

Ultimately, I need to send a URL string as the request. Below in red is what the API request needs to look like:
If I send that string via the browser with my proper API key, I get a perfect json result, so my key works. I have a BO to receive the response and have set the REST object to "Write into object in Context" and the object should receive multiple zip codes and store each to the ZipCode attribute of the ReturnedZipCodes object via mapping. When I trigger the API service, it creates a single object but does not include the ZipCode attribute. I have tried putting the entire request string into the Base URL param, though the docs say not to. I have also tried putting just the zipcodeapi.com URL in the base URL param and putting the remainder in the request body as text/xml, which returns null. It seems so simple...

All thoughts appreciated.
API Request.png
API Request.png (16.71 KiB) Viewed 2320 times
#53099 by kklosson
Sun Feb 09, 2020 7:54 pm
Here's some log information I found (key is redacted). So the json data is being returned, just not committed to the BO.

Calling REST URL http://www.zipcodeapi.com/rest/KEYREDAC ... 031/5/mile .Parameter string is null Body string is:null
REST Service returned:{"zip_codes":[{"zip_code":"22151","distance":4.733,"city":"Springfield","state":"VA"},{"zip_code":"22032","distance":3.188,"city":"Fairfax","state":"VA"},{"zip_code":"22003","distance":3.159,"city":"Annandale","state":"VA"},{"zip_code":"22030","distance":4.57,"city":"Fairfax","state":"VA"},{"zip_code":"22034","distance":1.689,"city":"Fairfax","state":"VA"},{"zip_code":"22036","distance":1.689,"city":"Fairfax","state":"VA"},{"zip_code":"22037","distance":1.689,"city":"Fairfax","state":"VA"},{"zip_code":"22038","distance":1.689,"city":"Fairfax","state":"VA"},{"zip_code":"22031","distance":0,"city":"Fairfax","state":"VA"},{"zip_code":"22047","distance":2.19,"city":"Falls Church","state":"VA"},{"zip_code":"22042","distance":3.448,"city":"Falls Church","state":"VA"},{"zip_code":"22081","distance":1.347,"city":"Merrifield","state":"VA"},{"zip_code":"22082","distance":1.347,"city":"Merrifield","state":"VA"},{"zip_code":"22116","distance":1.347,"city":"Merrifield","state":"VA"},{"zip_code":"22118","distance":1.347,"city":"Merrifield","state":"VA"},{"zip_code":"22119","distance":1.347,"city":"Merrifield","state":"VA"},{"zip_code":"22120","distance":2.318,"city":"Merrifield","state":"VA"},{"zip_code":"22185","distance":2.582,"city":"Vienna","state":"VA"},{"zip_code":"22046","distance":4.685,"city":"Falls Church","state":"VA"},{"zip_code":"22027","distance":3.19,"city":"Dunn Loring","state":"VA"},{"zip_code":"22180","distance":2.534,"city":"Vienna","state":"VA"},{"zip_code":"22124","distance":4.581,"city":"Oakton","state":"VA"},{"zip_code":"22183","distance":2.839,"city":"Vienna","state":"VA"},{"zip_code":"22184","distance":2.839,"city":"Vienna","state":"VA"},{"zip_code":"22043","distance":4.53,"city":"Falls Church","state":"VA"},{"zip_code":"22181","distance":3.736,"city":"Vienna","state":"VA"}]}
FAULT: ERROR: org.openadaptor.adaptor.jms.JMSSink - txnCommit() failed with JMS Queue/Topic PublishException: org.openadaptor.adaptor.jms.PublishException: org.openadaptor.adaptor.jms.JMSPublisher - commit() called when not initialized
ERROR: transaction commit failed (will call rollback) , ERROR: org.openadaptor.adaptor.jms.JMSSink - txnCommit() failed with JMS Queue/Topic PublishException: org.openadaptor.adaptor.jms.PublishException: org.openadaptor.adaptor.jms.JMSPublisher - commit() called when not initialized
#53100 by Jaymer
Sun Feb 09, 2020 8:17 pm
So the issue is usually the Aware bo structure.
Please post a screen shot of the bo fields
#53101 by kklosson
Sun Feb 09, 2020 9:16 pm
Here is the BO that receives the Zip Codes. It's called ReturnedZipCodes. Also a shot of the mapping screen for the Reply.
ReturnedZipCodes.png (8.87 KiB) Viewed 2312 times
ZipCode BO.png
ZipCode BO.png (47.31 KiB) Viewed 2312 times
#53102 by Jaymer
Sun Feb 09, 2020 11:04 pm
its all in the structure

i was going to do more, but dont have the time.
you dont really need the form... or need to run this.
the key are the TWO BOs needed to store the result

those zips on the form are not used.
am using the hardcoded Base URL in the REST as you did

(40.14 KiB) Downloaded 322 times
#53103 by Jaymer
Mon Feb 10, 2020 12:40 am
Take a look at this [hypothetical] JSON reply:

Code: Select all{
  "AnalysisID": "101",
  "Confidence": "99",
  "NumZips": 4,
  "zip_codes": [
      "zip_code": "22151",
      "distance": 4.733,
      "city": "Springfield",
      "state": "VA"
      "zip_code": "22032",
      "distance": 3.188,
      "city": "Fairfax",
      "state": "VA"
      "zip_code": "22003",
      "distance": 3.159,
      "city": "Annandale",
      "state": "VA"
      "zip_code": "22030",
      "distance": 4.57,
      "city": "Fairfax",
      "state": "VA"

Its easy to see that the "header" record contains 4 fields... and then the "child" recs (from the array).
So if you were to build BOs for this, you would have succeeded first try (most likely).
But the ZipCode reply fools you because it doesn't look like there are any "header" fields - and there aren't really, which is why you'd want to have only 1 file for the reply.

Who is online

Users browsing this forum: No registered users and 52 guests