在Matlab中使用Curl(windows10)的请求给出了错误消息
我正在向服务器发送一个curl命令,但收到一条我不理解的错误消息 我需要发送到服务器的请求是在Matlab中使用Curl(windows10)的请求给出了错误消息,matlab,curl,Matlab,Curl,我正在向服务器发送一个curl命令,但收到一条我不理解的错误消息 我需要发送到服务器的请求是 body=$(cat << EOF { "order": { "units": "100", "instrument": "EUR_USD", "timeInForce": "FOK", "type": "MARKET", "positionFill": "DEFAULT" } } EOF ) curl \ -X POST \ -H
body=$(cat << EOF
{
"order": {
"units": "100",
"instrument": "EUR_USD",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}
}
EOF
)
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN>" \
-d "$body" \
"https://api-fxtrade.oanda.com/v3/accounts/<ACCOUNT>/orders"
body=$(catJSON似乎没有正确引用
试试这个:
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d "{\"order\": {\"units\": \"100\", \"instrument\": \"EUR_USD\", \"timeInForce\": \"FOK\", \"type\": \"MARKET\", \"positionFill\": \"DEFAULT\" }}" "https://api-fxpractice.oanda.com/v3/accounts/AccountID/orders"
使用代理进行测试
通过对JSON引号进行适当转义,如上面的CURL命令行所示,在HTTPS代理中查看JSON时看起来是正确的: