Android Question How to get JSON error text ?

Discussion in 'Android Questions' started by b4auser1, Jun 19, 2015.

  1. b4auser1

    b4auser1 Well-Known Member Licensed User

    I tried to get JSON error text using Job.GetString

    If Job.Success = False Then
    Dim ErrorText As String = Job.GetString
    but some errors b4a raises exception about misssing cache file
    for others returns text, but not with error data.

    I can still see in the log error text like below. As far I understand the text is logged by internal proc inside Httputils2 framework.

    {
    "error" : "invalid_grant",
    "error_description" : "Code was already redeemed."
    }

    How to correct the problem ?
     
  2. DonManfred

    DonManfred Expert Licensed User

    Are you reusing the AUTH-code? Or did you get a fresh auth code before sending the request. looks like an auth-code can only be used once. For future requests you need to get a new one i believe.
     
  3. b4auser1

    b4auser1 Well-Known Member Licensed User

    Thank you for fast response.

    I don't have a problem to get correct access token. But I want to process situations, if an error is returned.
    In order to process exceptions, I need to get data describing the error. Rest API returns the data as a JSON object. Now I can't get this JSON object - details in my previous message.
     
  4. DonManfred

    DonManfred Expert Licensed User

    Code:
    Dim parser As JSONParser
    parser.Initialize(your json 
    string here)
    Dim root As Map = parser.NextObject
    Dim error As String = root.Get("error")
    Dim error_description As String = root.Get("error_description")
     
    Peter Simpson likes this.
  5. b4auser1

    b4auser1 Well-Known Member Licensed User

    Httputils2 framework works incorrectly and Job.GetString doesn't return correct text with JSON data.

    For some errors, b4a raises exception about misssing cache file, for others it returns text, but not with correct JSON error data.

    It's necessary to fix something to support correct text returned with Job.GetString if Job.Success = False.
     
  6. b4auser1

    b4auser1 Well-Known Member Licensed User

Loading...