Echilon
Echilon

Reputation: 10264

"Invalid web service call, missing value for parameter" with jQuery

I have a site which uses WebForms. It has a service which used to work, but my host recently migrated the site to a new server. The DB connections are working but my asmx service is now broken.

I have this signature:

[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public string GetJarLabel(string type, string serialized)
{

Which I'm calling with this jQuery:

var requestData = {
            "type":  "jam",
            "serialized": JSON.stringify(data)
};
$.ajax({
            type: "POST",
            url: "/Labels.asmx/GetJarLabel",,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processData: false,
            data: JSON.stringify(requestData),
            error: function(xhr, status, ex) {
                ...snip
            },
            success: function(r) {
                ...snip
            }
        });

enter image description here

The request seems to be submitted as far as I can tell, but the service responds 500: Invalid web service call, missing value for parameter: 'type'. I've tried switching to GET, stringifying, not stringifying but nothing works. I'm sure this worked before the migration but can't see how that would have affected it.

Upvotes: 0

Views: 1248

Answers (2)

Echilon
Echilon

Reputation: 10264

I tried this on a different machine from home today (was previously at work). It seems work have some kind of weird outbound proxy setup which is interfering with requests. I guess the lesson is to try over a VPN from a different country or a phone.

Upvotes: 0

JamesS
JamesS

Reputation: 2300

Below you can see your ajax call. You're stringfying something called lblData. What is that? Thats not what your are declaring above. Try passing requestData instead.

$.ajax({
        type: "POST",
        url: "/Labels.asmx/GetJarLabel",,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        processData: false,
        data: JSON.stringify(lblData),
        error: function(xhr, status, ex) {
            ...snip
        },
        success: function(r) {
            ...snip
        }
    });

I'm presuming that whatever lblData is, it doesn't have a definition for type.

Upvotes: 1

Related Questions