System.InvalidOperationException: Missing parameter in webservice RRS feed

  • Question

  • User1804579801 posted

    Dear all,

    I have webservice method where i should upload 2 files from service .But when i tested the service from postman every time iam getting  error 

    "System.InvalidOperationException: Missing parameter: ProjectId." 

    my webservice 

        public string App_Insert_Business_Acquisition_Tracker_Client_Visit_Log(string ProjectId, string ProjectStatus, string Comments, string VisitDateTime, string Latitude, string Longitude, string DeviceDetails, string ContactPerson, string NetInvoiced, string RevisedOrderValue, string Status)
            string msg = "";
            using (SqlConnection con = new SqlConnection(strConn))
                SqlCommand cmd = new SqlCommand("App_Insert_Business_Acquisition_Tracker_Client_Visit_Log", con);
                cmd.CommandType = CommandType.StoredProcedure;
                    //var request = HttpContext.Current.Request;
                    //IEnumerable<string> headers = request.Headers.GetValues("X-Api-Key");
                    //  var auth_key = headers.FirstOrDefault();
                    var auth_key = "O53KxcrNEqlVnjv4VOzC1qQIMflF47kxAb0LYdVfQ19xGaZlQTmioun6kPCLCNCbNLynQR6y2XTJ8NtXEKg";
                    //  HttpPostedFile file = HttpContext.Current.Request.Files["image"];
                    HttpPostedFile file = HttpContext.Current.Request.Files[0];
                    string saveFile = file.FileName;
                    file.SaveAs(Server.MapPath("/bat_files/" + saveFile));
                    cmd.Parameters.AddWithValue("@ProjectId", ProjectId);
                    cmd.Parameters.AddWithValue("@ProjectStatus", ProjectStatus);
                    cmd.Parameters.AddWithValue("@Comments", Comments);
                    cmd.Parameters.AddWithValue("@VisitDateTime", VisitDateTime);
                    cmd.Parameters.AddWithValue("@VoiceAttachment", saveFile);
                    //cmd.Parameters.AddWithValue("@Attachment", file2.FileName);
                    cmd.Parameters.AddWithValue("@Latitude", Latitude);
                    cmd.Parameters.AddWithValue("@Longitude", Longitude);
                    cmd.Parameters.AddWithValue("@DeviceDetails", DeviceDetails);
                    cmd.Parameters.AddWithValue("@Auth_Key", auth_key);
                    cmd.Parameters.AddWithValue("@ContactPerson", ContactPerson);
                    cmd.Parameters.AddWithValue("@NetInvoiced", NetInvoiced);
                    cmd.Parameters.AddWithValue("@RevisedOrderValue", RevisedOrderValue);
                    cmd.Parameters.AddWithValue("@Status", Status);
                    //return d1.data;
                    msg = "File uploaded";
                catch (Exception ex)
                    msg = "Could not upload file: " + ex.Message;
            return msg;

    I have commented on another parameter "Attachment"  as I wanted to check if one file uploaded successfully or no. Please suggest 

    Friday, March 13, 2020 12:18 PM

All replies

  • User475983607 posted

    The error is very clear.  Your client code forgot to pass the ProjectId to the web method.  Can you share the client code?

    Friday, March 13, 2020 12:23 PM
  • User-1330468790 posted

    Hi, nagapavanich,


    The error tells everything. You should pass the parameter "ProjectId" when you test the service.


    I noted that you are using postman, which should be the API testing tool, to test the service.

    It would be an easier way to do post through "Form" within setting the "Content-Type" property to "application/x-www-form-urlencoded".

    That way, you will not forget the parameters since you will find them all in the text boxes.


    I am using another testing tool but basically they are the same.




    Hope this can help you.

    Best regards,


    Monday, March 16, 2020 5:37 AM