douduocuima61392 2015-10-27 04:12
浏览 107

日期时间UTC格式。 POST请求无法识别? [OANDA]

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂