React-native POST request in android over https return network error

谁都会走 提交于 2019-12-06 09:16:17

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

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',
}

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" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!