【发布时间】:2017-08-05 10:06:58
【问题描述】:
我正在将动态值传递给测试方法并执行 curl 请求。 $PARAMETERS 有问题。
当我执行以下方法时,我得到如下错误
错误:-
curl: option -F: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information
功能:-
testing() {
local URL=$1
local HTTP_TYPE=$2
local PARAMETERS=$3
# store the whole response with the status at the and
HTTP_RESPONSE=$(curl -w "HTTPSTATUS:%{http_code}" -X $HTTP_TYPE $URL $PARAMETERS)
echo $HTTP_RESPONSE
}
URL='https://google.com'
HTTP_TYPE='POST'
PARAMETERS="-F 'name=test' -F 'query=testing'"
result=$(testing $URL $HTTP_TYPE $PARAMETERS)
仅供参考,上面是一个示例方法,并且正在使用 shell 脚本。请告诉我如何解决这个问题?
【问题讨论】: