25°

cURL命令后不工作在Windows命令提示符,因为使用单引号

背景

在学习 Flowable 工作流的官方文档时, https://tkjohn.github.io/flowable-userguide/ 2.4.3. 启动流程实例

复制文档的

curl --user rest-admin:test -H "Content-Type: application/json" -X POST -d '{ "processDefinitionKey":"holidayRequest", "variables": \[ { "name":"employee", "value": "John Doe" }, { "name":"nrOfHolidays", "value": 7 }\]}' http://localhost:8080/flowable-rest/service/runtime/process-instances

报错

curl: (3) Port number ended with 'h'
curl: (6) Could not resolve host: variables
curl: (3) [globbing] bad range specification in column 2
curl: (3) [globbing] unmatched brace in column 1
curl: (3) Port number ended with 'e'
curl: (6) Could not resolve host: value
curl: (6) Could not resolve host: John Doe
curl: (3) [globbing] unmatched close brace/bracket in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (3) Port number ended with 'n'
curl: (6) Could not resolve host: value
curl: (6) Could not resolve host: 7
curl: (3) [globbing] unmatched close brace/bracket in column 1
{"message":"Bad request","exception":"JSON parse error: Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null'); nested exception is com.f
asterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (PushbackInputStream); lin
e: 1, column: 2]"}

解决方案:

cURL命令后不工作在Windows命令提示符,因为使用单引号,

把单引号改成双引号,把类似 { "name":"nrOfHolidays", "value": 7 } 中的双引号使用 '\' 转义一下.即可. 修改后完整版如下:

curl --user rest-admin:test -H "Content-Type: application/json" -X POST -d "{ \"processDefinitionKey\":\"holidayRequest\", \"variables\": [ { \"name\":\"employee\", \"value\": \"John Doe\" }, { \"name\" :\"nrOfHolidays\", \"value\": \"7\" }]}" http://localhost:8080/flowable-rest/service/runtime/process-instances

本文由【观】发布于开源中国,原文链接:https://my.oschina.net/u/4049480/blog/3159761

全部评论: 0

    我有话说: