使用URL编码数据进行卷曲

时间:2014-09-06 02:09:46

标签: json url curl parameters

Curl拒绝以网址编码形式或JSON以外的任何形式接收PUT请求数据。

我在OS X上使用curl命令。

以下是我正在运行的命令的相关部分:

curl <other options> -H 'Content-Type: application/x-www-form-urlen-coded' --data-urlencode '_id=postcodes-backup-monday'

我尝试的任何内容都会遇到空白拒绝和以下错误消息:

&#34; {&#34;错误&#34;:&#34; bad_request&#34;,&#34;原因&#34;:&#34;无效的UTF-8 JSON&#34;}&# 34;

我对此的回答是:当然这是有效的JSON - 我以url编码的形式发送数据......

如果我也尝试过,该命令也拒绝将有效的JSON解析为有效的JSON。

1 个答案:

答案 0 :(得分:0)

您发送的数据不是JSON。

你应该

curl <other options> -H 'Content-Type: application/x-www-form-urlen-coded' \
--data-urlencode '{"_id":"postcodes-backup-monday"}'
相关问题