【发布时间】:2020-10-16 12:03:10
【问题描述】:
我知道这个问题可能是多余的,但我正在尝试通过 POST 请求将 png 文件发送到 Flutter 中的 Microsoft Custom Vision。 这是我的代码:
void _makeRequest (File file) async {
String url = "<url>";
Map<String, String> headers = {
"Content-Type": "application/octet-stream",
"Prediction-Key": "<key>",
};
var bytes = file.readAsBytesSync();
var response = await http.post(
url,
headers: headers,
body: bytes,
);
print(response.body);
print(response.statusCode);
}
当我运行这段代码时,我得到了这个响应:
{"code":"ErrorUnknown","message":"The request entity's media type 'appliction/octet-stream' is not supported for this resource."}
【问题讨论】:
-
你能添加你的“url”字段的值吗?看起来您可能发布到了错误的端点
-
"southcentralus.api.cognitive.microsoft.com/customvision/v3.0/…" 我做了一个“测试”,从互联网上发送了一张图片,它响应正常
标签: flutter http-post http-status-code-415 microsoft-custom-vision