Skip to content Skip to sidebar Skip to footer

React-native Post Request In Android Over Https Return Network Error

Tried to create user account through https POST request under react-native with axios, while it always failed on android with a 'network error'. axios('https://'+DEST_URI, { meth

Solution 1:

I was facing the same issue with android 'POST' requests. Turned out to be headers issue as mentioned in the link: https://github.com/facebook/react-native/issues/5222#issuecomment-170239302

Adding the following headers fixed the issue for me

headers = {
'Accept': 'application/json',
'Authorization': 'Bearer ' + this.authToken,
'Content-Type': 'application/x-www-form-urlencoded',
}

Solution 2:

Related to the issue Upgrade to OkHttp3 on the react-native repository.

Deactivate http2 from your proxy that is what causing the problem. You can try to upgrade to react-native v0.27 they mention in the change log that they fixed this problem but for me didn't work.

I had to disable the http2 feature in ngnix to make it work.

disabling http2 really is this simple, just change this line in your ngnix config file from:

listen 443 ssl http2;

to

listen 443 ssl;

then reload your config:

service nginx reload

More info about http2 and ngnix can be found here

Solution 3:

I guess you have not a internet permission in your AndroidManifest.xml file.

Please add this line into you AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />

Post a Comment for "React-native Post Request In Android Over Https Return Network Error"