Home Analyst Portal

API Returning Invalid Character

Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
edited September 2017 in Analyst Portal
I'm trying to get the users phone number from the API. I have the following but when I run it I'm just getting 'Invalid Character'

$.getJSON('/search/getObjectProperties', {"id": session.user.Id}) ,function(data) { var obj=jQuery.parseJSON(data); console.log(obj.BusinessPhone); });

Any ideas?


  • Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
    Unintuitively getJSON() does not return a JSON object, and your parseJSON() therefore fails to parse it. Instead, you get a jqXHR object, which you can just treat as a normal JS object, so you can do data.BusinessPhone, without parsing it first.
  • Alex_MarshAlex_Marsh Premier Partner Advanced IT Monkey ✭✭✭
    Excellent! Now I just need to try and shoehorn this into one of my other scripts so I can inject the businessphone into another field
Sign In or Register to comment.