Ich*_*man 6 api android postman flutter
我收到这个错误
Unhandled Exception: SocketException: OS Error: No route to host,
errno = 113, address = (my url api), port = 42392
Run Code Online (Sandbox Code Playgroud)
尝试使用以下代码访问它时:
final String basicAuth = 'Basic ' + base64Encode(utf8.encode('$authUsername:$authPassword'));
final String _grantType = "password";
http.Response response = await http.post(
Uri.encodeFull("this is my url api"),
headers: <String, String>{
"authorization": basicAuth,
'content-type': 'application/x-www-form-urlencoded',
},
body: {
"username": username,
"password": password,
"grant_type": _grantType,
},
);
Run Code Online (Sandbox Code Playgroud)
我已经使用邮递员尝试了该 URL,并且工作正常,我写得正确吗?我不确定是否放置授权基本授权码
解决了 !!!!
如果您想从外部设备访问 api,那么您需要与本地主机处于同一网络才能执行此操作,请单击此链接以帮助您连接到本地主机。
Xammp -> 网络 -> 启用;
希望这对您有帮助。
| 归档时间: |
|
| 查看次数: |
22129 次 |
| 最近记录: |