Jump to content
Sign in to follow this  
leonardo.salmaso

New Trade Order "ErrorCode":500,"ErrorMessage":"Server error.","HttpStatus":0

Recommended Posts

Hi guys! I’m working on an app that will be able to place new Trade Order. I’m calling BeginTrade method , but when I call EndTrade, the CIAPI throws an exception. I attached my code and CIAPI response.

CIAPIRpcConnection.TradesAndOrders.BeginTrade(TradeOrderRequestDto,callback2 =>
 {
     try
     {
          var newTradeDTO = CIAPIRpcConnection.TradesAndOrders.EndTrade(callback2); // here blows up 
REQUEST
{CityIndex.JsonClient.ApiException: The remote server returned an error: NotFound.
REQUEST INFO:
ItemState       : Pending
Url             : https://ciapipreprod.cityindextest9.co.uk/TradingApi/order/newtradeorder
Method          : POST
Target          : order
UriTemplate     : /newtradeorder
Parameters      :
    trade: {
   "MarketId": 400481147,
   "Currency": null,
   "AutoRollover": true,
   "Direction": "buy",
   "Quantity": 1.0,
   "QuoteId": null,
   "BidPrice": 0.99094,
   "OfferPrice": 0.99131,
   "AuditId": "------------",
   "TradingAccountId": -----------,
   "IfDone": [
      null
    ],
    "Close": null
   }

CIAPI RESPONSE:

ResponseText    : {"ErrorCode":500,"ErrorMessage":"Server error.","HttpStatus":0}
   ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass2.<EndGetResponse>b__1(Object sendState)
   ......

Share this post


Link to post
Guest mrdavidlaing

Could you give us some more information to help track down whether the issue lies on the server side, the client side or the network connection in between.

Try placing the same trade via the Javascript test console – using code like the following:

var userName = "{==YourUsername==}";
doPost('/session',{ "UserName": userName, "Password": "password"}, function (data, textCode) {
    setRequestHeader("UserName", userName);
    setRequestHeader("Session", data.Session);

    //New Trade
    doPost('/order/newtradeorder',
       { "trade": { "MarketId": 400481147, "Currency": null,  "AutoRollover": true, "Direction": "buy",
                       "Quantity": 1.0, "QuoteId": null,
                       "BidPrice": 0.99094, "OfferPrice": 0.99131, "AuditId": "12345",
                       "TradingAccountId": {==YourTradingAccountId==}, "IfDone": [], "Close": null
                   }
      } );
 });

Do you get a similar error?

Share this post


Link to post

This my code and the CIAPI responde.

Target          : order

UriTemplate : /newtradeorder Parameters :

trade: {

“MarketId”: 400481146, “Currency”: null, “AutoRollover”: true, “Direction”: “sell”, “Quantity”: 1.0, “QuoteId”: null, “BidPrice”: 0.81957, “OfferPrice”: 0.81992, “AuditId”: “sbPreProdFX3224665”, “TradingAccountId”: xxxxxxxx, “IfDone”: [

null

], “Close”: null } Request URI :https://ciapipreprod.cityindextest9.co.uk/TradingApi/order/newtradeorder Request Headers :

UserName: XX132724
Session: c9825922-978f-4244-8db2-ed3bf659da9a

CacheDuration : 00:00:00 RetryCount : 0 ThrottleScope : trading Expiration : 0001-01-01 00:00:00Z ResponseText : {“ErrorCode”:500,“ErrorMessage”:“Server error.”,“HttpStatus”:0} —–> System.Net.WebException: The remote server returned an error: NotFound. —–> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<>cDisplayClass2.b1(Object sendState) at System.Net.Browser.AsyncHelper.<>cDisplayClass4.b1(Object sendState) at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.Dispatcher.<>cDisplayClass4.b3() at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) at System.Windows.Threading.Dispatcher.OnInvoke(Object context) at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args) at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at CityIndex.JsonClient.RequestController.<>cDisplayClass6`1.b5(IAsyncResult ar, RequestHolder requestHolder) at CityIndex.JsonClient.ThrottedRequestQueue.<>cDisplayClass3.b1(IAsyncResult ar) at System.Net.Browser.ClientHttpWebRequest.<>cDisplayClassa.b8(Object state2) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()

at CityIndex.JsonClient.ApiAsyncResult

1.End()
   at CityIndex.JsonClient.Client.EndRequest[TDTO](ApiAsyncResult1 asyncResult)

 at CIAPI.Rpc.Client.EndRequestTDTO at CIAPI.Rpc.Client._TradesAndOrders.EndTrade(ApiAsyncResult

1 asyncResult)
   at NGM.Business.Services.TradesAndOrdersServices.TradesService.<>c__DisplayClass16.<>c__DisplayClass19.<CreateMarketOrderAsync>b__14(ApiAsyncResult

1 callback2) at CityIndex.JsonClient.ApiAsyncResult

1..ctor(ApiAsyncCallback

1 cb, Object state, Boolean completed, String responseText, Exception error) at CityIndex.JsonClient.CacheItem

1.CompleteResponse(String json, Exception exception)
   at CityIndex.JsonClient.RequestController.<>c__DisplayClass6

1.b5(IAsyncResult ar, RequestHolder requestHolder) at CityIndex.JsonClient.ThrottedRequestQueue.<>cDisplayClass3.b1(IAsyncResult ar) at System.Net.Browser.ClientHttpWebRequest.<>cDisplayClassa.b__8(Object state2) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()

Exception ResponseText: {“ErrorCode”:500,“ErrorMessage”:“Server error.”,“HttpStatus”:0}}

Thanks!.

Share this post


Link to post

Any feedback? The same issue is observed when CIAPI service are called by WCF services. Is this problem with POST request and Headers? I’ve seen examples and the only difference is that they pass session id and user name as parameters of query string.

Share this post


Link to post
Guest mrdavidlaing

This my code and the CIAPI responde.

Target          : order

UriTemplate : /newtradeorder Parameters :

trade: {

“MarketId”: 400481146, “Currency”: null, “AutoRollover”: true, “Direction”: “sell”, “Quantity”: 1.0, “QuoteId”: null, “BidPrice”: 0.81957, “OfferPrice”: 0.81992, “AuditId”: “sbPreProdFX3224665”, “TradingAccountId”: xxxxxxxx, “IfDone”: [

null

], “Close”: null } Request URI :https://ciapipreprod.cityindextest9.co.uk/TradingApi/order/newtradeorder Request Headers :

UserName: XX132724
Session: c9825922-978f-4244-8db2-ed3bf659da9a

CacheDuration : 00:00:00 RetryCount : 0 ThrottleScope : trading Expiration : 0001-01-01 00:00:00Z ResponseText : {“ErrorCode”:500,“ErrorMessage”:“Server error.”,“HttpStatus”:0} —–> System.Net.WebException: The remote server returned an error: NotFound. —–> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.cDisplayClass2.b1(Object sendState) at System.Net.Browser.AsyncHelper.cDisplayClass4.b1(Object sendState) at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.Dispatcher.cDisplayClass4.b3() at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Delegate.DynamicInvokeOne(Object[] args) at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) at System.Delegate.DynamicInvoke(Object[] args) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) at System.Windows.Threading.Dispatcher.OnInvoke(Object context) at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args) at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at CityIndex.JsonClient.RequestController.cDisplayClass6`1.b5(IAsyncResult ar, RequestHolder requestHolder) at CityIndex.JsonClient.ThrottedRequestQueue.cDisplayClass3.b1(IAsyncResult ar) at System.Net.Browser.ClientHttpWebRequest.cDisplayClassa.b8(Object state2) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()

at CityIndex.JsonClient.ApiAsyncResult

1.End()
   at CityIndex.JsonClient.Client.EndRequest[TDTO](ApiAsyncResult1 asyncResult)

 at CIAPI.Rpc.Client.EndRequestTDTO at CIAPI.Rpc.Client._TradesAndOrders.EndTrade(ApiAsyncResult

1 asyncResult)
   at NGM.Business.Services.TradesAndOrdersServices.TradesService.<>c__DisplayClass16.<>c__DisplayClass19.<CreateMarketOrderAsync>b__14(ApiAsyncResult

1 callback2) at CityIndex.JsonClient.ApiAsyncResult

1..ctor(ApiAsyncCallback

1 cb, Object state, Boolean completed, String responseText, Exception error) at CityIndex.JsonClient.CacheItem

1.CompleteResponse(String json, Exception exception)
   at CityIndex.JsonClient.RequestController.<>c__DisplayClass6

1.b5(IAsyncResult ar, RequestHolder requestHolder) at CityIndex.JsonClient.ThrottedRequestQueue.cDisplayClass3.b1(IAsyncResult ar) at System.Net.Browser.ClientHttpWebRequest.cDisplayClassa.b__8(Object state2) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()

Exception ResponseText: {“ErrorCode”:500,“ErrorMessage”:“Server error.”,“HttpStatus”:0}}

Thanks!.

Please try the same request using the Javascript test console or the FlexITP. We need to know whether the issue is with the WP7 client library or with your internet connection

Share this post


Link to post
Guest mrdavidlaing

Any feedback? The same issue is observed when CIAPI service are called by WCF services. Is this problem with POST request and Headers? I’ve seen examples and the only difference is that they pass session id and user name as parameters of query string.

Please try the same request using the Javascript test console or the FlexITP. We need to know whether the issue is with the WP7 client library or with your internet connection

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×