I'm trying to create an order using the OANDA REST api endpoints.
http://developer.oanda.com/rest-live/orders/#createNewOrder
I'm having trouble with setting the expiry variable during the request, as I am trying to create a limit order, so I have to set it.
The code I use to generate the format for the UTC datetime generates a date of this
2016-04-23T15:57:05.000Z
However I get this message
POST https://api-fxtrade.oanda.com/v1/accounts/<accNumber>/orders&instrument=EUR_USD&units=1&side=buy&type=limit&expiry=2016-04-23T15:57:05.000Z&price=1.0 HTTP/1.1
{"code":38,"message":"No matching handler for request with uri \/v1\/accounts\/309077\/orders&instrument=EUR_USD&units=1&side=buy&type=limit&expiry=2016-04-23T15:57:05.000Z&price=1.0","moreInfo":"http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"}
Perhaps its something about the UTC DateTime needing to be encoded? I made a curl request with a URI encoded date time but got this message still.
curl -H "Authorization: Bearer XXX-YYY" --data "instrument=EUR_USD&units=1&side=buy&type=limit&expiry=2016-04-01T00%3A00%3A00Z&price=1.0" https://api-fxtrade.oanda.com/v1/accounts/<Acc Number>/orders
{
"code" : 41,
"message" : "Received request with malformed body: 'instrument=EUR_USD&units=1&side=buy&type=limit&expiry=2016-04-01T00%3A00%3A00Z&price=1.0'",
"moreInfo" : "http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"
}
The only message I can get differently than a malformed body is when I send a curl request with an expiry like this
curl -H "Authorization: Bearer XXXXX-YYYYY" --data "instrument=EUR_USD&units=1&side=buy&type=limit&expiry=2016-04-01&price=1.0" https://api-fxtrade.oanda.com/v1/accounts/<Acc Number>/orders
{
"code" : 1,
"message" : "Invalid or malformed argument: expiry",
"moreInfo" : "http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"
}
Any help is appreciated.