Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:53:47+00:00 2026-05-27T09:53:47+00:00

Keep the question here short and sweet. I’m Getting a 500 error when I

  • 0

Keep the question here short and sweet. I’m Getting a 500 error when I try and pass a JSON object to an ASMX webservice. Note that if I declare the params as individual variables (eg. int ID, int OrderHeaderID, etc) I do not receive the error. I can’t see why the problem is happening, I have successfully passed objects in this manner before, possibly with different syntax but I can’t recall.

JS:

var returnHeader = {
    ID: -1,
    OrderHeaderID: parseInt(getQueryStringKey('OrderID')),
    StatusID: 1,
    DeliveryCharge: 0,
    CreatedBy: $('span[id$="lblHidUsername"]').text(),
    ApprovedBy: $('span[id$="lblHidUsername"]').text()
};

$.ajax({
    type: "POST",
    url: 'Order.asmx/SaveReturnHeader',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: JSON.stringify(returnHeader),
    success: function (result) {
        if (result.Status == 'OK') {
            GetReturns();
        }
        else {
            $('#divMessage').show().html(result.Data.Message).addClass('error');
        }
    },
    error: function (x, e) {
        if (x.status == 500) {
            $('#divMessage').show().html('An unexpected server error has occurred, please contact support').addClass('error');
        }
    }
});

Server:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public object SaveReturnHeader(BEReturnHeader returnHeader)
{
    try
    {
        return new
        {
            Status = "OK",
            Data = ""
        };                
    }
    catch (Exception ex)
    {
        return new
        {
            Status = "ERROR",
            Data = ex
        }; 
    }
}

Object (abbreviated for simplicity):

public int ID ...
public int OrderHeaderID ...
public int StatusID ...
public decimal DeliveryCharge ...
public string CreatedBy  ...
public string ApprovedBy ...

Request Data:

{"ID":-1,"OrderHeaderID":5,"StatusID":1,"DeliveryCharge":0,"CreatedBy":"77777777","ApprovedBy":"77777777"}

Response Headers:

HTTP/1.1 500 Internal Server Error
Date: Mon, 05 Dec 2011 16:38:36 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
jsonerror: true
Cache-Control: private
Content-Type: application/json
Content-Length: 91

Response Data:

{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

FIX:

Had to wrap the JSON object so it was recognized on the server:

var params = {
            returnHeader: {
                ...
            }
        };

...
data: JSON.stringify(params),
...

{"returnHeader":{"ID":-1,"OrderHeaderID":5,"StatusID":1,"DeliveryCharge":0,"CreatedBy":"77777777","ApprovedBy":"77777777"}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:53:47+00:00Added an answer on May 27, 2026 at 9:53 am

    You’re only passing in the object’s properties, not the entire object container. So, the web method is expecting something like this instead:

    {returnHeader:{"ID":-1,"OrderHeaderID":5,"StatusID":1,"DeliveryCharge":0,"CreatedBy":"77777777","ApprovedBy":"77777777"}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting a 'List does not exist' error whenever I try and use
Ok, I'll try and keep this short, sweet and to-the-point. We do massive GeoIP
EDIT I added this note to explain why I keep this question here. I
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
Noob question here. I'm following this example/tutorial to try and isolate a problem I
So this is more of a generic question. I seem to keep finding myself
EDIT: SOLVED Thanks Brooks. Your question led me to keep digging into if the
I keep getting this : DeprecationWarning: integer argument expected, got float How do I
This is probably a noob question that I will get slated for but here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.