WebApi לא מצליח לקבל קבצים

בוקה3

New member
WebApi לא מצליח לקבל קבצים

שלום חברים,

אני צריך לפתח WEBAPI אשר מקבל קובץ/קבצים.
הבידקות אני עושה דרך postman, מצרף לשם קובץ ושולח
(לא יכול לעלות תמונות כרגע אעלה עוד מעט) .

הבעיה שחי היא ב httpRequest.Files.Count לא מגיעים קבצים.
ז"א שהקובץ לא מגיע.

הנה הקוד שלי אשמח לעזרה.
כמו כן אם משהו לא תקין אשמח לתחקון או קוד חדש.

תודה רבה

קוד:
public async Task<HttpResponseMessage> PostSendFiles([FromBody]Object jsonData)
        {
            string serviceName = "GetFormData";
            Logs.Info(String.Format("------ Start {0} ---------", serviceName));
            HttpResponseMessage res = new HttpResponseMessage();
            try
            {
                HttpResponseMessage result = null;
                var httpRequest = HttpContext.Current.Request;
                if (httpRequest.Files.Count > 0)
                {
                    var docfiles = new List<string>();
                    foreach (string file in httpRequest.Files)
                    {
                        var postedFile = httpRequest.Files[file];
                        var filePath = HttpContext.Current.Server.MapPath("~/" + postedFile.FileName);
                        postedFile.SaveAs(filePath);

                        docfiles.Add(filePath);
                    }
                    result = Request.CreateResponse(HttpStatusCode.Created, docfiles);
                }
                else
                {
                    result = Request.CreateResponse(HttpStatusCode.BadRequest);
                }
                return result;

            }
            catch (Exception ex)
            {
                Logs.Error("Exception", ex);
                return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                throw;
            }
            finally
            {
                Logs.Info(String.Format("------ END {0} ---------", serviceName));
            }
        }
 

בוקה3

New member
מצרף צילום מסך של ה postman



 
למעלה