curl Content type ‘applicationx-www-form-urlencoded;charset=UTF-8‘ not supported

curl Content type ‘applicationx-www-form-urlencoded;charset=UTF-8‘ not supported,第1张

curl Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported

使用curl请求java接口,返回报错

array(5) {
  ["timestamp"]=>
  string(19) "2021-11-10 11:20:26"
  ["status"]=>
  int(415)
  ["error"]=>
  string(22) "Unsupported Media Type"
  ["message"]=>
  string(76) "Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"
  ["path"]=>
  string(21) "/base/searchDrugTaboo"
}

原因:curl请求时,设置的content-type不对或者未设置。

解决方案:

$headers = array("content-type: application/json; charset=UTF-8");

在curl请求中,header内加上content-type设置,参数请求是json格式。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5437430.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存