Hi,
I have created following Web Method:
[WebMethod] [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public string PostData(Class1 param) { //Class1 param= new Class1(); //param.FirstName = "Shashi"; string Result = ""; // Result= JsonConvert.SerializeObject(param); Result = "success"; return Result; }
Class:
[Serializable] public class Class1 { private string name; public string FirstName { get { return name; } set { name = value; } } }
Web.conf:
<?xml version="1.0"?><configuration><appSettings/><connectionStrings/><system.web><compilation debug="true" targetFramework="4.0"/><authentication mode="Windows"/><pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web></configuration>
Now When Invoked from POSTMAN getting Error:
- Selected Method as POST
- In URL in entered : http://localhost:31901/Service.asmx/PostData
- In Body Checked "raw" and Type JSON(application/json)
- Passed parameter as {"FirstName":"Shashikant"}
But getting Error:
{"Message": "Invalid web service call, missing value for parameter: 'param'.","StackTrace": " at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType": "System.InvalidOperationException" }
Please help!