I'm trying to receive a lengthy base64 string from my Android Client and then decode it to a bitmap in my Web API Project to be uploaded as an image to an Azure BLOB Storage. However, the project returns this message and refuses to take in the parameters:
Request URL Too Long
HTTP Error 414. The request URL is too long.
Obviously the base64 string is very long. How do I get around this and accept the parameters? I've looked around stack for a similar question but none of the answers clearly state ho to fix it in a Web API. Thank you!
Here's a code snippet from my method:
[HttpPost]
[Route("api/addnewpost")]
public IHttpActionResult AddNewMediaActivity(string base64String, string caption, string email, string type)
{
byte[] f = Convert.FromBase64String(base64String);
//more code........
}
My Client code on Android:
HttpClient hc = new DefaultHttpClient();
String message;
HttpPost p = new HttpPost("http://mymobileaddress.azure-mobile.net/api/addactivity?base64String=" + image + "&caption=" + caption + "&email=" + email + "&type=" + type );
JSONObject object = new JSONObject();
try {
object.put("base64String", image);
object.put("email", image);
object.put("base64String", image);
} catch (Exception ex) {
}
try {
message = object.toString();
p.setEntity(new StringEntity(message, "UTF8"));
p.setHeader("Content-type", "application/json");
p.setHeader("ACCEPT", "application/json");
p.setHeader("X-ZUMO-APPLICATION", mobileServiceAppId);
HttpResponse resp = hc.execute(p);
if (resp != null) {
if (resp.getStatusLine().getStatusCode() == 204)
{
}
}
Log.d("ER", "" + resp.getStatusLine().getStatusCode());
} catch (Exception e) {
e.printStackTrace();
}