Fail Calling my API

wealokwealok Member ✭✭
edited January 13 in Xamarin.Android

Everything works just fine in IOS but in Android sometimes it works correctly but other times it doesn't, any clue what can cause the problem?
Thank you.

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    in Android sometimes it works correctly but other times it doesn't

    Did this issue occur in the same deivce or different versions of devices?

    And some similar issue cases you can refer to:
    https://stackoverflow.com/questions/58887696/failed-call-api-http-in-android
    https://stackoverflow.com/questions/55579919/cannot-call-local-rest-api-from-android-device

    Related tutorial:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/accessing-remote-data

  • wealokwealok Member ✭✭
    edited January 13

    to test my android stuff i use a Samsung SM-T390, for IOS i use the virtual studio emulator, in the ios emulator everything works fine and in android half of the times it reaches the api just fine aswell

  • JarvanJarvan Member, Xamarin Team Xamurai

    Did any errors or exceptions occur? Both the server and the client may cause failing to call the api, such as passing wrong parameters and access timeout.

  • wealokwealok Member ✭✭

    No, didn't occur any exceptions or errors, every time i click in the button to go to the next page it should either go to the next page or return a message that is provided by the webservice saying the type of error that we have for example "the name doesn't exist in the bd" ,etc, defined by us in the webservice, when i click the button it returns a blank massage that was supposed to be a webservice message (remembering that only happens half of the times, some times it reaches the api just fine).

    basically in IOS the same code works 100% of the times, and in android works 50% of the times(always tested android in the same device).

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited January 16

    The cause should be in server, please check the log info in backend.

  • ChristChrist BEMember ✭✭

    Hello all,
    @wealok -> what does it mean -> In Android sometimes it works correctly but other times it doesn't
    Could you share a log a some code about the exception ?

  • wealokwealok Member ✭✭

    @Christ the problem is that there's no exception, the code works fine, just half of the time don't reach the api

  • ChristChrist BEMember ✭✭

    @wealok -> perhpas try with postman do you have the same comportement with postman ?

  • wealokwealok Member ✭✭

    ERROR System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The server returned an invalid or unrecognized response.
    at System.Net.Http.HttpConnection.SendAsyncCore (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00cf5] in :0
    --- End of inner exception stack trace ---
    at System.Net.Http.HttpConnection.SendAsyncCore (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x012e5] in :0
    at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync (System.Net.Http.HttpConnection connection, System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0012b] in :0
    at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0014b] in :0
    at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ba] in :0
    at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in :0
    at RiopeleMobile.Rest_Service.RestService.Planeamento_CT_ValidarOrdem (RiopeleMobile.PlanCT.Models.Estruturas+ValidarOrdem item) [0x000ef] in /Users/mac/Desktop/AppQua18122019/RiopeleMobile/Services/RestService.cs:2029 now i got this

  • JarvanJarvan Member, Xamarin Team Xamurai

    Please check the code about HttpConnection.SendAsyncCore method.

Sign In or Register to comment.