+ Start a Discussion

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session


I believe this is only recent, but I am no longer able to perform API actions against my development install using code that hasn't changed in quite some time.  When I run the code listed below, I get a error on the "Describe Object" call that says "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session".   It looks as though I'm getting a valid session ID back from the login call, but the subsequent API call doesn't seem to like it.   

The interesting thing is that I have a QA org that's on NA1 (my dev org is also on NA1) that has no problems with the code below.   Also, this problem is only happening for my dev org when I run the code from our corporate environment.  If the code runs on our production environment (which have different IP ranges and are locate outside of our corporate office), then it works properly as well.

Is is possible that there is some sort of configuration set in my dev org that doesn't agree with the code below as it's run from our corporate environment?  I've played around with the "Lock sessions to the IP address from which they originated" setting in my dev org, but it didn't seem to do anything.

Here is the code I am running that seems to work for every other install except my dev org:

          Dim sfdcService As New SforceService

          Dim loginResult As New LoginResult

          sfdcService.SessionHeaderValue = New SessionHeader

          loginResult = sfdcService.login(username, password)

          sfdcService.Url = loginResult.serverUrl

          sfdcService.SessionHeaderValue.sessionId = loginResult.sessionId

          Dim results As SForce.DescribeSObjectResult = sfdcService.describeSObject("Lead")


Any help would be greatly appreciated.

Thank you,


Best Answer chosen by Admin (Salesforce Developers) 
The fix for this problem went out at the weekend.

All Answers

The fix for this problem went out at the weekend.
This was selected as the best answer
I am experiencing the same problem with my Org. In one of the post, you mentioned to log a case with Salesforce.com Support. Should I do that ? The difference with my problem is that I have script schedule to load data(thru dataloader) every hour, we changed the timings for the first run and this error comes in only during the first run.
Even though in the next run the files get processed just that its not meeting our targeted uptime for data to be displayed on salesforce.com
Yes, go ahead and log a case. Are you sure the login doesn't have login hours restrictions turned on ?


Where can i check that ?



I got the place where we see the restricted hours but nothing specified there.
So I guess i will put in the case.
Thanks for your help,

I'm facing the same problem. Code that used to work fine, starts throwing an "Invalid Session ID found in SessionHeader" error. Were you able to solve this issue?

I have brand new code but getting the same reply trying to execute line of apex code from javascript:


<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap
/envelope/" xmlns:sf="http://soap.sforce.com/schemas/package/TNAPIAuth"><soapenv:Body><soapenv:Fault
><faultcode>sf:INVALID_SESSION_ID</faultcode><faultstring>INVALID_SESSION_ID: Invalid Session ID found
in SessionHeader: Illegal Session</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>


Examples from pdf cookbook do not work for me either.


This is my class:


global class TNAPIAuth { WebService static String token() { return 'it works'; } }

 And this is my page:



<script type="text/javascript" src="/js/functions.js"></script> <script type="text/javascript" src="/soap/ajax/15.0/connection.js"></script> <script type="text/javascript" src="/soap/ajax/15.0/apex.js"></script> ........... function doSomething() { try { result = sforce.apex.execute("TNAPIAuth", "token", {}); alert('no problems - it is working'); }catch(error) { alert(error); } };



Is anyone able to call apex from java on http(s)://c.na6.visual.force.com ?


Hi Aniche,


Iam facing the same prob in my Org where the extraction of records through Batch process stop in the middle .When i see the logs , i see this error Invalid session Id, missing session key.


This error comes very rarely and unable to find a solution for this.


Did you manage to get a solution for this ?


Thank you in Advance.