我正在尝试使用颤振插件 HTTP 发出 HTTP POST 请求,但出现标题错误。有谁知道这是什么原因,因为在我的其他应用程序中这工作得很好?
await http.post(Uri.encodeFull("https://api.instagram.com/oauth/access_token"), body: {
"client_id": clientID,
"redirect_uri": redirectUri,
"client_secret": appSecret,
"code": authorizationCode,
"grant_type": "authorization_code"
});
Run Code Online (Sandbox Code Playgroud)
jam*_*lin 131
为了提高编译时类型安全性,package:http0.13.0 引入了重大更改,使以前接受Uris 或Strings 的所有函数现在只 接受Uris。您将需要显式使用从sUri.parse创建s。(以前在内部为您调用。)UriStringpackage:http
| 旧代码 | 用。。。来代替 |
|---|---|
http.get(someString) |
http.get(Uri.parse(someString)) |
http.post(someString) |
http.post(Uri.parse(someString)) |
(等等。)
在您的具体示例中,您将需要使用:
await http.post(
Uri.parse("https://api.instagram.com/oauth/access_token"),
body: {
"client_id": clientID,
"redirect_uri": redirectUri,
"client_secret": appSecret,
"code": authorizationCode,
"grant_type": "authorization_code",
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33777 次 |
| 最近记录: |