Content-Type header [application/x-www-form-urlencoded] is not supported [duplicate]

不羁的心 提交于 2019-12-03 12:38:15

After changing the enclosing quotes from ' to ", escape the quotation marks " used inside the parameters as below:

curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d "{\"query\": {\"simple_query_string\" : {\"fields\" : [\"content\"], \"query\" : \"foo bar -baz\"}}}"

An alternative is to put the json into a file, and use the @ prefix for the parameters.

json.txt

{
  "query": {
    "simple_query_string" : { 
      "fields" : ["content"], 
      "query" : "foo bar -baz"
    }
  }
}

and run curl as below:

curl -XGET gitlab.server:9200/ -H "Content-Type: application/json" -d @json.txt
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!