Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello


I have a problem when i am calling web services from json

it is Error: Internal Server Error [Error Code: 500] showing.


My code is :-

C#
var DataJO = [
                            {
                                LO: x;,
                                AC: "FILING FEE",
                                MAC: "",
                                amount: 500,
                            }
                       ]
            usrData = { SecurityKey: "xxx", UserToken: "567", Key: "1", Vouchers: DataJO };
            break;
    }
    var fullURL = srvURL + "/" + srvOps;
    var postData = usrData;
    $('#divresult').html("Calling: " + fullURL);
    $.post(fullURL, postData)
    .done(function(data) {
        $('#divresult').html($('#divresult').html() + "<br/>Success Result: ");
        $('#txtresult').val(JSON.stringify(data, " "));
        if (args == 'AU')
            $('#hdnToken').val(($.parseJSON(data)).UserInfo[0].UserToken);
    })
    .fail(function(msg) {
        $('#divresult').html($('#divresult').html() + "<br/>Error: ");
        $('#txtresult').val("Error: " + msg.statusText + " [Error Code: " + msg.status + "]");
    });

    return false;
}




Any solution.
Posted
Comments
Kornfeld Eliyahu Peter 1-Feb-15 4:35am    
500 means that your web server (IIS probably) wasn't able to handle the request (post?). It not even got to your code...You should see the details of that 500!
Jimut123456789 1-Feb-15 4:44am    
But it is working when i am sending only string except JSON file.
Kornfeld Eliyahu Peter 1-Feb-15 4:52am    
'Stringify' your JSON before sending...
Jimut123456789 1-Feb-15 5:48am    
I have done that.

1 solution

Based on the comment, I suspect that you need to pass JSON string instead of json object.
Try the following change:
var postData = JSON.stringify(usrData, undefined, 4);

This should work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900