Jump to content
Sign in to follow this  
buzz

Session is valid but still getting 4011

Recommended Posts

I have been trying to post to "order/newstoplimitorder" but getting error 4011 

{'HttpStatus': 401, 'ErrorMessage': 'Session is not valid', 'ErrorCode': 4011}

The json that i'm trying to post looks like this:

{
	"OrderId": 0,
	"MarketId": 401484392,
	"MarketName": "GBP/USD",
	"AutoRollover": false,
	"isTrade": false,
	"Direction": "Buy",
	"Quantity": 10.0,
	"BidPrice": 1.31441,
	"OfferPrice": 1.3146,
	"AuditId": null,
	"TradingAccountId": <my trading account id>,
	"PositionMethodId": 1,
	"Applicability": "GTC",
	"Guaranteed": false,
	"TriggerPrice": 1.314,
	"UserName": "<my username>",
	"Session": "f4835c33-220f-4309-940d-cd4175ee6265"
}

I post that with headers:

{'Content-type': 'application/json', 'Accept': 'text/plain'}

 

I have verified that my session is valid by posting to "session/validate" 

{'IsAuthenticated': True}

What am I missing?

 

Share this post


Link to post

Hi Buzz,

Every request to the API must carry 2 pieces of authentication (username and session) in the request header, not in the request body. This is the likely reason why the server is complaining that the session is not valid, as it is not getting that piece of information in the request header.

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
Sign in to follow this  
×