Jump to content

Recommended Posts

Hi, I am trying to do login using CIAPI.

 

This is the URI I am using:

"http://ciapipreprod.cityindextest9.co.uk/TradingApi/session";

 

When I use username "DM631479" with password "password". Everything seems ok.

 

================

Request

================

POST http://ciapipreprod.cityindextest9.co.uk/TradingApi/session HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: ciapipreprod.cityindextest9.co.uk
Content-Length: 59
Expect: 100-continue
Connection: Keep-Alive

{"UserName":"DM631479","Password":"password","AppKey":null}

 

================

Response

================

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Web Server
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 10 Nov 2014 11:31:09 GMT
Content-Length: 112

{"Session":"1ef8dd5f-7663-4c84-a786-b6ea58600a90","PasswordChangeRequired":false,"AllowedAccountOperator":false}

 

 

But when I use the username, password and app key that is given by City Index, I get a error response.

 

================

Request

================

POST http://ciapipreprod.cityindextest9.co.uk/TradingApi/session HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: ciapipreprod.cityindextest9.co.uk
Content-Length: 61
Expect: 100-continue
Connection: Keep-Alive

{"UserName":"DM423291","Password":"*********","AppKey":"*********"}

 

================

Response

================

HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Web Server
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 10 Nov 2014 11:33:32 GMT
Content-Length: 156

{"HttpStatus":401,"ErrorMessage":"The credentials used to authenticate are invalid.  Either the username, password or both are incorrect.","ErrorCode":4010}

 

 

Please advice.

 

Thanks.

 

Share this post


Link to post

Hello Vincent,

 

It appears that you have a test account on the Live environment rather than an account in Pre-Production. Your call that you pasted is trying to access the Pre-Prod test harness. 

 

Please try that call again using the Live environment test harness at: https://ciapi.cityindex.com/tradingapi.

 

The address for both PP and Live test harnesses are on the API documentation page so you have it for future reference: http://docs.labs.cityindex.com/#TestHarness.htm%3FTocPath%3DGetting%2520Started%7C_____5

 

Please let me know if that fixes the problem or if it's still not working.

 

Thanks a lot!

Share this post


Link to post

Hi, I've been trading with IG's API for a while, but am looking to move to CityIndex.
 
My first hurdle seems to be logging into the API.
 
I tried:
 

curl "https://ciapi.cityindex.com/TradingApi/session" -H 'Content-Type: application/json; charset=UTF-8' -d '{"UserName":"DM158617","Password":"xxxxx"}'

 
and got...
 

{"Session":"c0989dfe-9045-44fb-89a8-515e0cf33e9c","PasswordChangeRequired":false,[u][b]"AllowedAccountOperator":false[/b][/u]}

So, assumed that I cannot use my demo account in the live environment, back to the documentation and your post above, and found the pre-production environment, so tried...

curl "https://[u][b]ciapipreprod.cityindextest9.co.uk[/b][/u]/TradingApi/session" -H 'Content-Type: application/json; charset=UTF-8' -d '{"UserName":"DM158617","Password":"xxxxxxx"}'

but now I get

{"HttpStatus":401,"ErrorMessage":"The credentials used to authenticate are invalid.  Either the username, password or both are incorrect.","ErrorCode":4010}

 
I'd really appreciate some help to get me started please!
Rory

Share this post


Link to post

Hello Rory,

 

I believe one of my colleagues created a demo account for you to use in the Pre-Production environment. That should enable you to login and get started? If you still have problems in this area please let us know.

 

Kind Regards

PM!

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
×