Jump to content

Recommended Posts

Hi, I am a basic developer, I have built my Forex application using Gain Capital services library, I've connected to efxnow.com, as I noticed that the API services are all updated, it does not work anymore. I was guessing that I just need to change the library which my application is using but I couldn't find that. I also tried posting directly to API and was returned an error, See attached image my post request.

So my question is do I need to change now and use the new GCAPI libraries or do I just need to change some fields along with the API request.
If I do need to change library, I am really confused how to get it done and I spent already so much time trying to figure this out, do I need to set up a Lightstreamer client and some connection with it, or do I just need to change the library?

I'll appreciate your help and waiting for it.

error.png

Share this post


Link to post

Hi,

Your account manager should have been in contact with you a few months ago informing that the old Gain API was being deprecated, and that we were switching to a newer one. Did that not happen? It would have given you time to develop your App to work with the replacement API, enabling you to connect and continue trade.

The old API is now discontinued so will no longer work with your app. Your account should have been migrated to be compatible wth our new API. What is needed is to develop your App to work with our new API. You should contact your account manager to verify that your account has been transitioned properly and to find out about the information you should have received about the switch in API.

Kind Regards, PM!

Share this post


Link to post

Thanks Physicsman for your reply.

First, My account manager never contacted me regarding this update as long as I didn't call him to ask what's going on.

Now he told me that, he sent me new credentials as my account expired along with their overall system update, and he gave me no directions how to develop this update on my side and just sent me a message directing me to ask for it here on the Support blog.

If you can send me a link to detailed steps how to get this done or if there's any way someone can help me in private messaging it will be really helpful.

Share this post


Link to post

Hello,

Apologies for the miscommunication. 

We don't have step by step instructions on writing an application to work with the API, but we do have the API documented with examples at: http://docs.labs.cityindex.com/. This should enable you to develop against the API. Should you have some queries regarding the REST portion of the API, you can post them here and we can take a look.

Kind Regards, PM!

 

Share this post


Link to post

I got that, but just one clarification, I understand now that I must actually develop the Gets and Posts which is different of what I did until now by using the library connected service, is this correct?

Share this post


Link to post

Hi, I got your answer clearly, what I only need right now is just a clarification about the Demo api - (haven't tried the Live yet), I am sending a request and I see that I'm getting a page of JavaScript in result, in my example I tried getting the Session Token using "https://ciapipreprod.cityindextest9.co.uk/TradingApi" along with its headers, do I need to then run this JavaScript (which I'm not an expert with) in order to get the result, or can I just get the result in Json immediately without anything else.

Thanks.

Share this post


Link to post

I actually think that the reason might be the GET, I just changed to POST, but as of now I'm always getting an error that I must provide the Content-Length.

So when I'm doing this to get the Content-Length:

var jsonString = JsonConvert.SerializeObject(request);
            byte[] data = Encoding.ASCII.GetBytes(jsonString);
            request.ContentLength = data.Length;

then I'm getting this:
 "'You must provide a request body if you set ContentLength>0 or SendChunked==true.  Do this by calling [Begin]GetRequestStream before [Begin]GetResponse.'

Is there any Code Example where I can see some complete requests, maybe I'll get it there...

I really appreciate you time, Thanks a lot!!

Share this post


Link to post
var url = "https://ciapi.cityindex.com/tradingapi/session";
//var url = "https://ciapipreprod.cityindextest9.co.uk/TradingApi/session";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = Method;
            foreach (var param in paramsPairs)
            {
                request.Headers.Add(param.Key, param.Value);
            }
WebResponse response = request.GetResponse();

 

Share this post


Link to post

OK - the error message " "'You must provide a request body..." makes sense now. 

When sending a call to /session in order to logon, your account credentials must be passed in the post request body. See LogOn in the API documentation.

Kind Regards, PM!   

Share this post


Link to post

The bottom half of the Logon page in the link I provided shows an example, and the credentials are passed in the post request body. That should fix the error message you are receiving once you send the account credentials in the body rather than the header.

Kind Regards, PM 

Share this post


Link to post

The AppComments is optional so you can leave it out. AppVersion is not strictly required for your purposes either so it won't be cause of any issues to you. 

Kind Regards, PM

Share this post


Link to post

Hi,

There are just 2 things you need to change in Postman to get the call working.

  1. In the Headers tab, set "Content-Type" as "application/json".
  2. In the Body, you need to select "raw" JSON and not form-data.

The call will now succeed.

image.png

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
×