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
[WebMethod]
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;
try
{
//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("@VoiceAttachment","");
//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);
con.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
con.Dispose();
//Context.Response.Write(JSONResult);
//return d1.data;
msg = "File uploaded";
}
catch (Exception ex)
{
msg = "Could not upload file: " + ex.Message;
ExceptionLogging.SendErrorToText(ex);
}
}
return msg;
}
I have commented on another parameter "Attachment" as I wanted to check if one file uploaded successfully or no. Please suggest