6
I have two apps, a local running Winform and a remote hosted Webapi.
Already send data to the served from Winform, the code is 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 wonder how I can put an image in this MEUOBJETO
to serialize everything together and send.
Could you do that? What the Server side would look like?
My server receives the data as follows:
[Route("MINHA ROTA")]
public HttpResponseMessage POST( [FromBody]MEUOBJETO obj)
{
if (ModelState.IsValid)
{
...
}
}