I have problem to write a POST request to upload an image from Xamarin Forms to API. I already have my selected photo in format byte array, but I have problem with POST request, code is below, any suggestions?
At firts I select photo in my gallery at mobile phone, I save it to variable like byte array, then I must to send it to API like POST, but here I have problems because I dont know how to write correct code to be working.
var zeton = await SecureStorage.GetAsync("Zeton");
var httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
httpWebRequest.ContentType = "multipart/form-data";
httpWebRequest.Headers.Add("Token", zeton);
httpWebRequest.Method = "POST";
Stream stream = httpWebRequest.GetRequestStream();
stream.Write(array, 0, array.Length);
stream.Close();