I want to send a string data, “” , in bytes format to server in android app. I uses the HttpClient but i think its not the right way, please help me how to do this?
in case of .net , i want similar code in java.
string boundary = Guid.NewGuid().ToString();
HttpWebRequest request = HttpWebRequest.Create(url)
as HttpWebRequest;
request.Method = "POST";
//request.ContentType = "application/json";
request.PreAuthenticate = true;
byte[] fulldata = Encoding.UTF8.GetBytes(data);
request.ContentLength = fulldata.Length;
using (Stream sw = request.GetRequestStream())
{
sw.Write(fulldata, 0, fulldata.Length);
}
First convert your string data to byte and by using ByteArrayEntity send data to server in byte format.
try like this