Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Droid having issue parsing response from api #4285


User avatar
0
soonjoo created

hello team,

I am having issue running the android app. using version 5.04 jquery + aspnet core. I connect my phone via wifi to debug. After the splash screen, I am prompted to log in. however, everything I do shows that returns the "A problem occurred while trying to communicate with the server. Do you want to try again?" error. Checking my database audit logs, the methods are called successfully without any exception. the call dies here:

in Application.Client.ApiClient.AbpApiClient

public async Task<T> GetAsync<T>(string endpoint, object queryParameters, string accessToken, bool stripAjaxResponseWrapper)
        {
            var httpResponse = GetClient(accessToken)
                .Request(endpoint)
                .SetQueryParams(queryParameters);

            if (stripAjaxResponseWrapper)
            {
                var response = await httpResponse.GetJsonAsync<AjaxResponse<T>>(); // < ------ DIES AFTER THIS LINE
                ValidateAbpResponse(response);
                return response.Result;
            }

            return await httpResponse.GetJsonAsync<T>();
        }

any help is much appreciated. Thank you.


11 Answer(s)
  • User Avatar
    0
    soonjoo created

    hello again, i forgot to mention previously i directly pointed to the development api service (online not localhost). And it manages to call GetAll for User configurations and Authenticate, then keeps dying at GetCurrentLoginInformations...

    so i tried localhost, but running the start-host.bat provided, and it manages to run successfully, for everything

    on the development api service online, the url is formed correctly when i look inside httpResponse variable, and paste the url into my browser it works, but it immediately dies on the await httpResponse.GetJsonAsync<AjaxResponse<T>>(); line

    thank you.

  • User Avatar
    0
    soonjoo created

    Hello again,

    I didnt know i could step inside that call. So i had debug it, and found it had caught this exception message:

    {Flurl.Http.FlurlHttpException: GET <a class="postlink" href="http://myprojectdev.azurewebsites.net/api/services/app/Session/GetCurrentLoginInformations">http://myprojectdev.azurewebsites.net/a ... formations</a> failed. Unexpected character encountered while parsing value: . Path '', line 0, position 0. ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x00043] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00053] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <c19705166c7c4a608e182e859c4de6d2>:0 at Newtonsoft.Json.JsonSerializer.Deserialize[T] (Newtonsoft.Json.JsonReader reader) [0x00000] in <c19705166c7c4a608e182e859c4de6d2>:0 at Flurl.Http.Configuration.NewtonsoftJsonSerializer.Deserialize[T] (System.IO.Stream stream) [0x00019] in <f0b4fb8d1d61489486317325ace33652>:0 at Flurl.Http.HttpResponseMessageExtensions+<ReceiveJson>d__01[T].MoveNext () [0x00121] in <f0b4fb8d1d61489486317325ace33652>:0 --- End of inner exception stack trace --- at Flurl.Http.HttpResponseMessageExtensions+<ReceiveJson>d__01[T].MoveNext () [0x00157] in <f0b4fb8d1d61489486317325ace33652>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.ApiClient.AbpApiClient+<GetAsync>d__251[T].MoveNext () [0x0007e] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Application.Client\ApiClient\AbpApiClient.cs:183 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.ApiClient.AbpApiClient+<GetAsync>d__241[T].MoveNext () [0x000c6] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Application.Client\ApiClient\AbpApiClient.cs:172 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.ApiClient.AbpApiClient+<GetAsync>d__221[T].MoveNext () [0x00027] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Application.Client\ApiClient\AbpApiClient.cs:156 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.Sessions.ProxySessionAppService+<GetCurrentLoginInformations>d__0.MoveNext () [0x00035] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Application.Client\Sessions\ProxySessionAppService.cs:10 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.ViewModels.LoginViewModel+<<SetCurrentUserInfoAsync>b__48_0>d.MoveNext () [0x00024] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Mobile.Shared\ViewModels\LoginViewModel.cs:256 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at MyCompany.MyProject.Core.Threading.WebRequestExecuter+<Execute>d__01[TResult].MoveNext () [0x002a1] in C:\Users\Justin\Source\Repos\MyProject\src\MyCompany.MyProject.Mobile.Shared\Core\Threading\WebRequestExecuter.cs:52 }

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @soonjoo,

    What is the value of httpResponse variable when you debug the code ?

  • User Avatar
    0
    soonjoo created

    hello, here is the httpResponse.. if i continue the code, it dies after this line

    var response = await httpResponse.GetJsonAsync<AjaxResponse<T>>();
    

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you try below code and see if the result is correct ?

    var response = await httpResponse.GetStringAsync();
    

    Also, please share the result with us.

  • User Avatar
    0
    soonjoo created

    hello,

    here is the response that I get.

    "�\b\0\0\0\0\0\0�\aI�%&/m�{J�J��t�\b�$ؐ@������iG#)���eVe]f@�흼��{���{���;�N'���?\fdl��J�ɞ!���?~|?"~�Guެ���G���u������G�>�f�b���f]w>A��G�"+��ٌ�5���s��g�͗ٲO�5\��yQ�/�i����G���}T�o{�d�4���Z;z�\b�"�>(����_Ϩ�7�+j&�M�M[-N��5k֓fZ�������ӬͿj��ۢ9[����|��EE/�ge��0g^\0z��Y��A�u�-gY=#tZ��4�>���\0\T�v^^���)5�ϲ�rM=�ͷ��y\u07b4����^S�E�Ω��E\b���u��՛�q���}���p{����ޣ{���|�w��a�ʮ����\bmvB*��\t����jY���1 ����ݽ���|�ժ,��������x\a�Q�:/���}���w��w���������=?������';;�v��9uN�B\��?z]\,��N�/�%�g��y�U]6�错Ph��uE\-߭���v^���٫����\nk�����g����K��m�6\0\0"

    not sure why its like that, any idea??

  • User Avatar
    0
    alper created
    Support Team

    looks like data from server is compressed. In AbpApiClient class we set Accept-Encoding as gzip,deflate. If you are using Azure, gzip compression is enabled by default for Azure Web Apps (As far as I know) Try removing that line for your production environment.

  • User Avatar
    0
    soonjoo created

    Thanks @alper, it works now...!

  • User Avatar
    0
    alper created
    Support Team

    you'r wellcome ;)

  • User Avatar
    0
    joe704la created

    I am having the same issue but the same fix didn't help. It fails in \src\PHS.Application.Client\ApiClient\AbpApiClient.cs on line 183. When it gets to line 183 and tries to var response = await httpResponse.GetJsonAsync<AjaxResponse<T>>(); it crashes in the android emulator.

    Any ideas?

  • User Avatar
    0
    alper created
    Support Team

    show the full-stack error message. the line of code throwing exception. what's your host (Azure, on-premise IIS, local Kestrel, local IIS)? Are you using different compression methods on the host side?