After a health amount of googling and trial here is what works in case
anyone else needs it. Note the content_type_json() inside POST:
URL_Orders<-'https://api-fxpractice.oanda.com/v3/accounts/{AccountID}/orders'
#replace {AccountID} with the account ID for the account (no {}) Token<-{Token} #fill with API Token generated from Oanda (no {})
#create the body for the request req = list( order = list(instrument="EUR_USD",
units="1000",
type="MARKET",
timeInForce="FOK",
positionFill="DEFAULT"
) )
#format body as JSON body<-toJSON(req, auto_unbox = T, pretty = FALSE)
#post request Test<-httr::POST(URL_Orders,
content_type_json(),
add_headers("Authorization" = paste("Bearer ", Token)),
body=body,
encode = "form",
verbose(data_out = TRUE, data_in = TRUE, info = TRUE))
- OP