wordpress - 错误 415 不支持提供的内容类型使用 IBM Cloud 文档翻译
问题描述
$auth = base64_encode( 'apikey:' . $apikey );
$endpoint = $url . '/v3/documents?version=2018-05-01';
$filename = ABSPATH.'wp-content/uploads/sample.pdf';
$filetype = wp_check_filetype('sample.pdf');
$response=wp_remote_post(
$endpoint,
array(
'body' => array(
'file' => '@' .$filename,
'source' => $source_lang,
'target' => $target_lang,
),
"headers" => array(
'Authorization' => 'Basic ' . $auth,
'content-type' => $filetype['type'],
)
)
);
print_r($response);
它给出了 Error:415 {\n "code": 415,\n "error": "Supplyed content type is not supported."\n}" 如何解决该问题
解决方案
推荐阅读
- automation - 需要帮助我处理 azure Runbooks 吗?
- mfc - 如何将 CFile 的内容复制到 CMemFile?
- android - @Bindable 不在 BR 类中生成字段
- google-apps-script - 如何通过文件上传修改 Google 表单响应
- docker - 如何使用基于 kaniko 的 gitlab-runner 构建 node.js 映像?
- ros - ROS Controller_manager
- python-3.x - 一次从 CSV 搜索字符串一行
- java - 有没有办法更改默认映射?
- memory-leaks - 为什么工厂查找表上的“字段指向的内存可能泄漏”
- ios - 无法使用 loadHTMLString 在 UIWebView 中加载 html 字符串,它显示一个白页