Я пытаюсь подключиться к Oanda API, но изо всех сил пытаюсь правильно отформатировать мой запрос.
Для документации API требуется следующий формат:
body=$(cat << EOF
{
"order": {
"price": "1.2000",
"timeInForce": "GTC",
"instrument": "EUR_CAD",
"units": "10000",
"clientExtensions": {
"comment": "New idea for trading",
"tag": "strategy_9",
"id": "my_order_100"
},
"type": "MARKET_IF_TOUCHED",
"positionFill": "DEFAULT"
}
}
EOF
)
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTHENTICATION TOKEN>" \
-d "$body" \
"https://api-fxtrade.oanda.com/v3/accounts/<ACCOUNT>/orders"
Мой запрос выглядит следующим образом:
require(httr)
body = list(instrument="EUR_USD", #These 4 are the required fields for this order type
units="1",
side="buy",
type="market"
)
auth = paste("Authorization: Bearer ",Token)
POST(add_headers("Content-Type: application/json",auth),
body = body,
url = 'https://api-fxpractice.oanda.com')
Однако я получаю следующий ответ 404:
Response [https://api-fxpractice.oanda.com]
Date: 2020-03-27 09:53
Status: 404
Content-Type: application/json
Size: 170 B
{
"code" : 38,
"message" : "No matching handler for the request is found",
"moreInfo" : "http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"
}
Что я делаю не так?