I have two applications, a WinForm running location and a WebApi hosted remote.
I already send data to the server from WinForm, the code looks like this:
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
string DATA = json_serializer.Serialize(MEUOBJETO);
HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.Proxy = null;
request.ContentType = "application/json";
byte[] dataStream = Encoding.UTF8.GetBytes(DATA);
Stream newStream = request.GetRequestStream();
newStream.Write(dataStream, 0, dataStream.Length);
newStream.Close();
request.GetResponse();
I would like to know how I can put an image in this MEUOBJETO
to serialize everything together and send.
Would you do it? How would the server side look?
My server receives the data as follows:
[Route("MINHA ROTA")]
public HttpResponseMessage POST( [FromBody]MEUOBJETO obj)
{
if (ModelState.IsValid)
{
...
}
}