question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error response external api

See original GitHub issue

Good evening, im developing an app with an external API. In web, ionic dev app and npx cap serve, all works fine, but when i try to package the app with capacitor and deploy in android studio, i have this error with all requests: Login Error: {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":null,"ok":false,"name":"HttpErrorResponse","message":"Http failure response for (unknown url): 0 Unknown Error","error":{"isTrusted":true}}

Does anyone know why?

Regards.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
Raertencommented, Jul 26, 2019

You can set usesCleartextTraffic="true" only for debug build like this AndroidManifest.xml

...
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="${usesCleartextTraffic}
        >
...

build.gradle

...
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "app.test"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [usesCleartextTraffic:false]
    }
    buildTypes {
        debug {
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
            manifestPlaceholders = [usesCleartextTraffic:true]
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
...
3reactions
chriswepcommented, Jul 26, 2019

Why don’t you just use http in development or use a good certificate even for development?

because by default the current android version blocks access to http. however as i now learned this can be disabled via android:usesCleartextTraffic="true", which i did now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Handle an External API Call Error in Workflows
One way to handle an error is to use Error Handling – If Error card. It's similar to try/catch logic. The card has...
Read more >
Okta Workflows How-To: Handling an External API Call Error
One way to handle an error is to use Error Handling – If Error card. It's similar to try/catch logic.
Read more >
Best Practices for REST API Error Handling - Baeldung
In this tutorial, we'll learn about some of the best practices for handling REST API errors, including useful approaches for providing users ...
Read more >
Troubleshoot External API Calls or Service Requests from ...
HTTP REST Troubleshooting · Step 1: Check the external service flow path · Step 2: Check if a proxy is sent with the...
Read more >
REST API status when external APIs are down - Best Practices
I'm working on a new API so I can take it any direction. In my case client invokes my API which internally invokes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found