windows下执行curl请求:
curl -H "Content-Type: application/json" http://192.168.160.49:9200/index_partners/_search?pretty -d '{"query":{"match_all":{}},"_source":["id","companyName","targetCompanyId","targetTenantId"],"from":0,"size":100}'
直接报错:"Unexpected character (''' (code 39)): expected a valid value (JSON String, Number, Array, Object, 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.InputStreamStreamInput); line: 1, column: 2]",具体报错信息截图如下:
文章来源:https://www.toymoban.com/news/detail-520861.html
同样的请求,在Linux下执行却是成功的。截图如下:
问题分析:
在windows命令行里执行上述curl请求,执行报错,因为windows系统里不能识别单引号',得换成双引号",换成双引号后再执行,还是报错,这时还得把请求参数里的"转义成\"。成功截图如下:
所以最终windows下能正确的执行curl命令为文章来源地址https://www.toymoban.com/news/detail-520861.html
curl -H "Content-Type: application/json" http://192.168.160.49:9200/index_partners/_search?pretty -d "{\"query\":{\"match_all\":{}},\"_source\":[\"id\",\"companyName\",\"targetCompanyId\",\"targetTenantId\"],\"from\":0,\"size\":100}"
到了这里,关于curl执行请求报错Unexpected character (‘‘‘ (code 39)): expected a valid value的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!