+ Start a Discussion


Problem when working with sforce API:
INVALID_SESSION_ID found in SessionHeader

Here is the code I use to login:

LoginResult loginResult = S.login(login, pass);
S.SessionHeaderValue = new SessionHeader();
S.SessionHeaderValue.sessionId = loginResult.sessionId;
S.Url = loginResult.serverUrl;

 Any news concerning this problem ?
The Support Service couldn't resolve my problem :s

Gareth DaviesGareth Davies
//execute the login placing the results  
//in a LoginResult object 
LoginResult loginResult = binding.login(username, password); 

//set the session id header for subsequent calls 
binding.SessionHeaderValue = new SessionHeader(); 
binding.SessionHeaderValue.sessionId = loginResult.sessionId; 

//reset the endpoint url to that returned from login 
This is the login code from developer's Sidekick which look just like yours and works fine. Where and when exactly do you receive the error message? 
 When I have seen the error message you describe, it is when a session has gone stale and timed out.
Thank you for your response...

I use this code in ASP.Net applications.
When connecting the first time it works fine.
If there is a new connection after a short time,
using the same sforce account, I get this message
on the first action query() or create() ...

I hope you understood my poor english ^^

Best regards,
I forget to say that it works perfectly earlier !
Gareth DaviesGareth Davies
Ce n'est aucun problème mon ami que je comprends tout que vous écrivez, mais je ne suis pas sûr je peux résoudre votre problème.
What about ensuring that you have a "new" S declared  - S = new SforceService incase there is something in that object.
Other than that, could it be a Session variable between Postbacks of the ASP.NET reverting to a previous session values?  or, conversly, that the on-pageload event overwrites the current one and resets it to a pre-initialised state?
Happy to be understood ^^

Thank you for your help. I'll check if it is an ASP.net session problem.