invalid web service call missing value for parameter

I am calling a Webmethod via jquery ajax call.

Here is my ajax method
 jQuery.support.cors = true;
        $.ajax({
            type: "GET",
            url: "mypage.aspx/GetConnectionDetail", 
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ "Id": Id, "accountKey": accountKey, "securityKey": securityKey, "connectionGUID": connectionGUID }),
            dataType: "json",

Open in new window


Here is my c# web method
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
  public static string GetConnectionDetail(string Id, string accountKey, string securityKey, string connectionGUID)
        {            
            return "my connection";
        }

Open in new window


When i am calling this method via POST Request it works fine but as i start calling the same method via GET request i am getting
invalid web service call missing value for parameter u0027/Id/u0027
. I debug my jquery function for missing parameters but the parameter is not missing. and if i switch to POST request it works fine.
Rohit SharmaAsked:
Who is Participating?

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

x
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.

Chris StanyonWebDevCommented:
My guess here is that you are trying to JSONify your data for a GET request. No need - a GET request should be passed as a querystring. Just use the data argument like so:

data: {
    "Id": Id,
    "accountKey": accountKey,
    "securityKey": securityKey,
    "connectionGUID": connectionGUID
},

Open in new window


jQuery will then automatically create the querystring for you.
0
Rohit SharmaAuthor Commented:
Thanks for your reply Chris Stanyon

this will not work as it throw a error  
Invalid JSON primitive
0
Chris StanyonWebDevCommented:
Ok. I think you need to remove the contentType  argument from your AJAX call as you're no longer sending it across as JSON. Remove this line:

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

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
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
AJAX

From novice to tech pro — start learning today.