Ajax POST - "Server encountered an error processing the request"

I have a jQuery Mobile app communicating to a WCF REST service.  The majority of my calls to the REST service are GETs.  However, one function uses a POST with JSON data.  

The POST works perfect on our development servers, so I'm fairly certain it isn't my code.  When I move it to production, it doesn't work any more.  I've included some logging in the REST service, so I have a good idea what method is being called as the mobile app communicates.  All the GETs go through fine, logging which method was used.  But the POST method doesn't even get called.

When I send the POST request I get "The server encountered an error processing the request.  See server logs for more details."  I've looked all through the Event Viewer on the server and can't find any messages pertaining to this.  We've also looked at the firewall logs, and I'm not seeing anything being blocked.  

I'm at a loss as to what is causing the error.

Here's my Ajax call:

        var JSONObject = {
            "customerID": customerID
            , "keyserialNumber": serialNumber
            , "issuedToName": newKeyHolderName
            , "userID": loggedInUserID
            , "keyIssuedUserID": newKeyHolderUserID
            , "signature": signature
            , "userEmail": loggedInUserEmail
            , "ccEmails": ccEmails

            url: baseUrl + 'UpdateKeyReceipt',
            type: 'POST',
            data: JSON.stringify(JSONObject),
            error: function(e){
            dataType: 'JSON',
            contentType: 'application/json; charset=utf-8',
            success: function (data) {

The REST service looks like this:

        [WebInvoke(Method = "POST",
           ResponseFormat = WebMessageFormat.Json,
           RequestFormat = WebMessageFormat.Json,
           BodyStyle = WebMessageBodyStyle.WrappedRequest,
           UriTemplate = "UpdateKeyReceipt")]
        string KeyReceiptData(Stream data);

  Method called:

        public string KeyReceiptData(Stream data)
            string logFile = @"\\ikraid\Clients\InstaKey\Logs\IKRestLog.txt";
            using (StreamWriter sw = File.AppendText(logFile))
                sw.WriteLine("KeyReceiptData: ");

            StreamReader reader = new StreamReader(data);

            string result = reader.ReadToEnd();

            UpdateKeyReceipt keyData = JsonConvert.DeserializeObject<UpdateKeyReceipt>(result);

            Helper.UpdateKeyReceipt(keyData.CustomerID.ToString(), keyData.KeySerialNumber.ToString(), keyData.IssuedToName.ToString(),
                keyData.UserID.ToString(), keyData.KeyIssuedUserID.ToString(), keyData.Signature.ToString(),
                keyData.UserEmail.ToString(), keyData.CCEmails.ToString());

            return "Received: " + result;

The log file never is written to, so I know it's not even reaching the method.

Anyone have anything I can do, or look at that might help, I'd very much appreciate it.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Just for giggles try using a URL that is relative rather than absolute.

Also try without the http:// prefix.

I have found in a couple of instances that the above fix the above problem.
IKtechAuthor Commented:

No, that only gives me a 404 error.  Thanks though.

Any other ideas?
Julian HansenCommented:
Try adding an error callback on the AJAX and dump the headers that you get back
error: function(jqXHR) {

Open in new window

IKtechAuthor Commented:
Finally figured this out. The problem was the line:

contentType: 'application/json; charset=utf-8',

I took that out of the ajax call and then was able to see progress in the log files. Then found an issue with the pdf creation in the rest service. Once the REST service was fixed, the app works like a charm.

I'd originally put that in as I'd seen many solutions that said that line must be included. Hadn't thought to take it out to test.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IKtechAuthor Commented:
My answer.  It works.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.