I am trying to post some custom image data on a web api. Please take a look at the method below.
public void Post(FlyerDetails FlyerDetails)
{
var httpRequest = HttpContext.Current.Request;
if (httpRequest.Files.Count > 0)
{
foreach (string file in httpRequest.Files)
{
var filePath = HttpContext.Current.Server.MapPath("~/Flyers/" + httpRequest.Files[file].FileName);
Bitmap bmp = new Bitmap(httpRequest.Files[file].InputStream);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawString(FlyerDetails.Message, new Font(FlyerDetails.FontColor, FlyerDetails.FontSize), Brushes.DarkRed, new PointF(0, 0));
g.Flush();
bmp.Save(filePath);
}
}
}
Now the problem is that I save this method with the parameter and publish data from fiddler, it shows me 415 Error of unsupported media type . If I remove the parameter, it works fine. But I really need to transfer the data along with the posted image.
Can anyone suggest a good way to do this?
thank
source
share