How do I handle a REST error - its displaying in a dialogBx

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

How do I handle a REST error - its displaying in a dialogBx

Post by Jaymer »

I'm calling FULLCONTACT.com

Its a service thats looks up info on the web about a person... you send it an email, it can return a detailed structure of information.
We mainly use it to get a picture of a Lead.
Been using it about 3 months in testing.
It does NOT use OAuth.
It returns a JSON string which populates 3 tables.

Problem is that sometimes Aware displays a Dialog Box which we rather the user not see.

Here's the Server Output:

Code: Select all

Calling REST URL https://api.fullcontact.com/v2/[email protected] .Parameter string is [email protected]
REST Service returned:{  "status" : 404,  "message" : "Searched within last 24 hours. No results found for this Id.",  "requestId" : "098aa020-4924-4364-81ef-faa8e80a1807"}
{  "status" : 404,  "message" : "Searched within last 24 hours. No results found for this Id.",  "requestId" : "098aa020-4924-4364-81ef-faa8e80a1807"}
java.lang.Exception: {  "status" : 404,  "message" : "Searched within last 24 hours. No results found for this Id.",  "requestId" : "098aa020-4924-4364-81ef-faa8e80a1807"}
And we see this Dialog box:
Screen Shot 2018-06-24 at 4.45.45 PM.png
Screen Shot 2018-06-24 at 4.45.45 PM.png (22.61 KiB) Viewed 14174 times
Normally, this is what the transaction looks like. No dialog. Populated the tables from JSON response correctly.

Code: Select all

Calling REST URL https://api.fullcontact.com/v2/[email protected] .Parameter string is [email protected]
REST Service returned:{  "status" : 200,  "requestId" : "6fe32891-80ba-4e8f-9720-8e8e017bafe5",  "likelihood" : 0.99,  "photos" : [ {    "type" : "facebook",    "typeId" : "facebook",    "typeName" : "Facebook",    "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/a8e840f012e98fbf0c5dcf69_17c50c4531ad3ba2ade271cdaa4002efade3e8f18615d50614385b3c240",    "isPrimary" : true  } ],  "contactInfo" : {    "familyName" : "Prescott",    "fullName" : "mary Prescott",    "givenName" : "mary"  },  "demographics" : {    "locationDeduced" : {      "normalizedLocation" : "Rocklin, California, United States",      "deducedLocation" : "Rocklin, California, United States",      "city" : {        "deduced" : false,        "name" : "Rocklin"      },      "state" : {        "deduced" : false,        "name" : "California",        "code" : "CA"      },      "country" : {        "deduced" : false,        "name" : "United States",        "code" : "US"      },      "continent" : {        "deduced" : true,        "name" : "North America"      },      "county" : {        "deduced" : true,        "name" : "Placer"      },      "likelihood" : 1.0    },    "gender" : "Female",    "locationGeneral" : "Rocklin, CA 95677 US"  },  "socialProfiles" : [ {    "type" : "facebook",    "typeId" : "facebook",    "typeName" : "Facebook",    "url" : "https://www.facebook.com/prescott"  }, {    "type" : "foursquare",    "typeId" : "foursquare",    "typeName" : "Foursquare",    "url" : "https://foursquare.com/user/11432",    "id" : "11432"  } ]}

The REST system is set to except a JSON reply and process the result into a BO.
But HOW to prevent the ugly error message that a user should not see?
I don't see any facility to process this.
It seems like FC.com responded with a valid Error Msg, but something in Aware decided to react to it as a "java.lang.Exception:"
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How do I handle a REST error - its displaying in a dialo

Post by PointsWell »

On receipt of the REST response are you able to test for the value of status? If so you could intercept that error and provide a more meaningful / graceful response to the user

The REST response for an error is the wrong shape for your Response BO which is what would be generating you error message (I am guessing). If AIM has nowhere to put the response then it’s acting like a process that is trying to populate a BO that is not in context.
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do I handle a REST error - its displaying in a dialo

Post by Jaymer »

bump
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How do I handle a REST error - its displaying in a dialo

Post by PointsWell »

Jaymer wrote:bump
Do you have message as an attribute in your response object?
Jaymer
Posts: 2450
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How do I handle a REST error - its displaying in a dialo

Post by Jaymer »

Sean
ok, thx for the tip - but no joy.

Way below, you can see the 2 requests and 2 replies.
Yes, it turned out I did NOT have "message" as one of the fields I was expecting (its not listed in the schema as a reply element).
I quickly added that with no help.

Because FC is returning a 404 Error, I believe Aware is seeing that as an error, and thus it brings up this box:
Screen Shot 2018-07-09 at 12.47.22 AM.png
Screen Shot 2018-07-09 at 12.47.22 AM.png (21.51 KiB) Viewed 14079 times
but thats not a box you want the user to see.

You can see from the Replies that if it had just received the reply, parsed and stored it, MY APP would have been able to display my own Error box if I chose to. I guess a tweak would be needed to indicate HOW we desire an error to be handled. I would now bet that ANY Rest reply of a 404 (or similar) would generate this FUGLY box in someone's App.

Also, I checked my stored file of Responses... its NOT storing the 404s... as I assume once it sees an error it doesn't parse and continue processing the reply. Its soooooo close to being what we need.

jaymer...

----------------------


this is the documented JSON example reply for a request using by Email:

Code: Select all

{
  "status": 200,
  "likelihood": 0.9,
  "requestId": "773e6782-62bb-4fc6-9f38-28ea0b5db261",
  "contactInfo": {
    "familyName": "Lorang",
    "givenName": "Bart",
    "fullName": "Bart Lorang",
    "websites":
    [
      {
        "url": "https://www.fullcontact.com"
      }
    ]
  },
  "demographics": {
    "locationGeneral": "Boulder, Colorado",
    "locationDeduced" : {
      "normalizedLocation" : "Boulder, Colorado",
      "deducedLocation" : "Boulder, Colorado, United States",
      "city" : {
        "deduced" : false,
        "name" : "Boulder"
      },
      "state" : {
        "deduced" : false,
        "name" : "Colorado",
        "code" : "CO"
      },
      "country" : {
        "deduced" : true,
        "name" : "United States",
        "code" : "US"
      },
      "continent" : {
        "deduced" : true,
        "name" : "North America"
      },
      "county" : {
        "deduced" : true,
        "name" : "Boulder",
        "code" : "Boulder"
      },
      "likelihood" : 1.0
    },
    "age": "33",
    "gender": "Male",
    "ageRange": "25-34"
  },
  "socialProfiles":
  [
    {
      "typeId": "twitter",
      "typeName": "Twitter",
      "url": "http://www.twitter.com/bartlorang",
      "id": 5998422,
      "username": "bartlorang",
      "bio": "CEO & Co-Founder of @FullContactAPI - Tech Entrepreneur and Angel Investor.",
      "followers": 631,
      "following": 485,
      "rss": "http://twitter.com/statuses/user_timeline/bartlorang.rss"
    },
    {
      "typeId": "linkedin",
      "typeName": "Linkedin",
      "url": "http://www.linkedin.com/in/bartlorang",
      "id": "6xtewkyGle",
      "username": "bartlorang",
      "bio": "Co-Founder & CEO at FullContact",
      "following": 1071,
      "followers": 1071
    },
    {
      "url": "http://about.me/lorangb",
      "username": "lorangb",
      "typeId": "aboutme",
      "typeName": "About Me"
    },
    {
      "url": "http://profiles.google.com/lorangb",
      "id": "114426306375480734745",
      "username": "lorangb",
      "typeId": "googleprofile",
      "typeName": "Google Profile"
    },
    {
      "url": "http://www.quora.com/bart-lorang",
      "username": "bart-lorang",
      "typeId": "quora",
      "typeName": "Quora"
    },
    {
      "url": "http://foursquare.com/lorangb",
      "username": "lorangb",
      "typeId": "foursquare",
      "typeName": "Foursquare",
      "id": "10245647"
    },
    {
      "url": "http://youtube.com/user/lorangb",
      "username": "lorangb",
      "rss": "http://youtube.com/rss/user/lorangb/videos.rss",
      "typeId": "youtube",
      "typeName": "Youtube"
    },
    {
      "url": "http://picasaweb.google.com/lorangb",
      "id": "114426306375480734745",
      "username": "lorangb",
      "rss": "http://picasaweb.google.com/data/feed/base/user/lorangb",
      "typeId": "picasa",
      "typeName": "Picasa"
    },
    {
      "url": "http://plancast.com/lorangb",
      "id": "1634762",
      "username": "lorangb",
      "typeId": "plancast",
      "typeName": "Plancast"
    },
    {
      "url": "https://plus.google.com/114426306375480734745",
      "id": "114426306375480734745",
      "username": "lorangb",
      "typeId": "googleplus",
      "typeName": "Google Plus"
    },
    {
      "url": "http://www.flickr.com/photos/39267654@N00/",
      "id": "39267654@N00",
      "rss": "http://api.flickr.com/services/feeds/photos_public.gne?id=39267654@N00",
      "typeId": "flickr",
      "typeName": "Flickr"
    }
  ],
  "organizations": [
    {
        "isPrimary": true,
        "name": "FullContact",
        "startDate": "2010-01",
        "title": "Co-Founder & CEO",
        "current": true
    },
    {
        "isPrimary": false,
        "name": "Dimension Technology Solutions",
        "startDate": "2009-06",
        "endDate": "2009-12",
        "title": "Owner",
        "current": false
    },
    {
        "isPrimary": false,
        "name": "Dimension Technology Solutions",
        "startDate": "2002-06",
        "endDate": "2006-06",
        "title": "Chief Technology Officer",
        "current": false
    },
    {
        "isPrimary": false,
        "name": "Dimension Technology Solutions",
        "startDate": "1996-06",
        "endDate": "2002-06",
        "title": "Partner / Development Manager",
        "current": false
    },
    {
        "isPrimary": false,
        "name": "Dimension Technology Solutions",
        "startDate": "2006-06",
        "endDate": "2009-06",
        "title": "President",
        "current": false
    }
  ],
"photos":
  [
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/ecf57683e2c22abb296f822377597290_fe346265298c3d008a4af9c54483809f55508dd4c238789dc9a115ae8395c381",
      "typeId": "twitter",
      "typeName": "Twitter"
    },
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/76fa9f05dce661f3dfbff6c2ea680cd7_c3360fe21ad70bde88addb0517369e17b6de0d94b85268e20688deda96d6b0a9",
      "typeId": "linkedin",
      "typeName": "Linkedin"
    },
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/image/45615034145b3b980973fdf87b213b81_97e5bd895444901bcfd4008362cb1008f617134ef6a8396eb292aed814a70c9a",
      "typeId": "quora",
      "typeName": "Quora"
    },
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/c1c2dfa135fa60399c4c1e3e1b8f7ace_9964024ac3eb12645ba7a4bec7aee722ad7735eb413b21a2b9bb008159aeda36",
      "typeId": "youtube",
      "typeName": "Youtube"
    },
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/ac4cac11df61b43c503d4c3101604742_80a63ae50b5cc0e8f9dacb522547d923f1b3961ca666fd661fb2b3f5656a644d",
      "typeId": "foursquare",
      "typeName": "Foursquare"
    },
    {
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/a508fc51b2d287175f36a44aead7438a_6be07253a0bbaf5929d148cc2fca7f266ffd41a1053862e2f3016594a134602d",
      "typeId": "googleplus",
      "typeName": "Google Plus"
    }
  ],
 }
Error Reply:
Calling REST URL https://api.fullcontact.com/v2/person.json?email=[email protected] .Parameter string is email=[email protected]
REST Service returned:{ "status" : 404, "message" : "Searched within last 24 hours. No results found for this Id.", "requestId" : "61976ccd-df9b-4c6c-b8b0-9b755a11db81"}


Normal Reply:
Calling REST URL https://api.fullcontact.com/v2/person.json?email=[email protected] .Parameter string is email=[email protected]
REST Service returned:{ "status" : 200, "requestId" : "e175e422-17d4-4a32-8c20-c7e28586ef7d", "likelihood" : 0.95, "photos" : [ { "type" : "google", "typeId" : "google", "typeName" : "GooglePlus", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/s ... 18a8b5cc4e", "isPrimary" : true }, { "type" : "twitter", "typeId" : "twitter", "typeName" : "Twitter", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/s ... b2c6f8c0aa", "isPrimary" : false } ], "contactInfo" : { "websites" : [ { "url" : "http://dematteiteam.blogspot.com" }, { "url" : "http://feeds.feedburner.com/RosevilleRe ... eVideoBlog" }, { "url" : "http://www.dematteiteam.com" } ], "familyName" : "DeMattei", "fullName" : "Chris DeMattei", "givenName" : "Chris" }, "organizations" : [ { "isPrimary" : false, "name" : "Keller Williams Realty", "startDate" : "2001", "title" : "Broker", "current" : true }, { "isPrimary" : false, "name" : "Realtor", "current" : false } ], "demographics" : { "locationDeduced" : { "normalizedLocation" : "Roseville, California, United States", "deducedLocation" : "Roseville, California, United States", "city" : { "deduced" : false, "name" : "Roseville" }, "state" : { "deduced" : false, "name" : "California", "code" : "CA" }, "country" : { "deduced" : false, "name" : "United States", "code" : "US" }, "continent" : { "deduced" : true, "name" : "North America" }, "county" : { "deduced" : true, "name" : "Placer" }, "likelihood" : 1.0 }, "gender" : "Male", "locationGeneral" : "Roseville, California, United States" }, "socialProfiles" : [ { "type" : "facebook", "typeId" : "facebook", "typeName" : "Facebook", "url" : "https://www.facebook.com/chrisdemattei" }, { "followers" : 84, "type" : "google", "typeId" : "google", "typeName" : "GooglePlus", "url" : "https://plus.google.com/113683232588891446837", "id" : "113683232588891446837" }, { "type" : "gravatar", "typeId" : "gravatar", "typeName" : "Gravatar", "url" : "https://gravatar.com/chrisdemattei", "username" : "chrisdemattei", "id" : "116556971" }, { "bio" : "There are...clients.", "followers" : 91, "following" : 91, "type" : "linkedin", "typeId" : "linkedin", "typeName" : "LinkedIn", "url" : "https://www.linkedin.com/in/chris-demattei-9793b913", "username" : "chris-demattei-9793b913", "id" : "45781293" }, { "bio" : "Real Estate Team Specializing in residential real estate in South Placer County and North Sacramento County since 1997. http://t.co/E6Yw6rSt0d", "followers" : 105, "following" : 67, "type" : "twitter", "typeId" : "twitter", "typeName" : "Twitter", "url" : "https://twitter.com/DematteiTeam", "username" : "DematteiTeam", "id" : "2786737003" } ]}
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply