I have an image of a barcode that I submit to a form. The image is posted to a restful API. The API receives the image, processes the image and throws an exception or returns a string of the barcode from the image.
Below is a snippet of my code
View -
<form name="somename" method="post" enctype="multipart/form-data"
action="/api/decoder">
<input type="file" name="ImageToDecode" accept="image/*" capture="camera" />
<input type="submit" value="Get Barcode..." />
< /form>
Api -
public class DecodeImageController : ApiController
{
public string Post()
{
var postedImage = HttpContext.Current.Request; // get the posted image
// do some stuff in here to read the barcode from the image
if (!could read image)
{
return barcode.ToString();
}
// barcode could not be found
throw new Exception("Barcode could not be read");
} // end post method
}
I am using Visual Studio 2013 MVC project. The API and the View are both in separate projects. This is what gets returned.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">10320972351</string>
This works fine, but now I want to call the API and have the returned barcode to my Controller.
Any direction would be helpful.
I am continuing to work on this as ideas pop into my head.