function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nickwick76nickwick76 

InvalidOrganizationIDException exception as response when calling WebToLead servlet

Hi all,

A supplier to us is calling the WebToLead servlet and gets the following response:

 

HTTP/1.1 200 OK Server:  Cache-Control: private Is-Processed: true Exception:system.organization.exception.InvalidOrganizationIDException Content-Type: text/html; charset=UTF-8 Content-Length: 0 Date: Thu, 09 Sep 2010 08:01:41 GMT

 Do anyone know what is wrong? What does this exception mean? It has worked in the future. To me it sounds like the Salesforce Org Id is wrong but I am not sure. It works in the Production environment but not in the Sandbox where this response comes from.

 

Thanks!

Niklas

 

hisrinuhisrinu

You can generate the new web2lead form from your sandbox organization and then compare the org id and url for both

carlos_redondocarlos_redondo

Hi All,

I'm experiencing same issue, and I double check both url and oid value.  Web-To-Lead HTML Form works fine but I can't get it working using a server code POST process, this is my server code sample:

 

// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "retURL=http://www.mysite.com&oid=00DdXXXXXXX&Campaign_ID=ABCXXXXXX&first_name=John&last_name=Smith&email=John_Smith@test.com&...";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "text/html; charset=UTF-8";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();

 

and response is always:

 

{Is-Processed: true Exception:system.organization.exception.InvalidOrganizationIDException
Content-Length: 0
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Date: Tue, 07 Feb 2012 15:47:08 GMT
Server:

}

 

Any idea why Organization ID is not recognized?  I tried moving oid value as first/last and in middle of request content information, but nothing seems to work.

 

 

Thanks for your help!

Carlos.

 

carlos_redondocarlos_redondo

Hi All,

I figured out what was wrong on my .Net Code, so for future reference this is how it works for me:

 

// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create("https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "oid=00Dd00XXXX&Campaign_ID=701d000XXX&first_name=JOHN&last_name=SMITH&email=JOHNSMITH@TEST.COM&company=...";

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();

 

As you can noticed from previous code trick was ContentType value.

 

Regards,

Carlos.