Reputation:
I want to send a jpeg image converted to base64 by json. The image is about 660kb in size and the characters after the conversion are approximately 2 million in length. What I need is to send it to a api ?? in a query string, if possible.
The error I get is that the string is too long. Are there any alternatives?
HttpClient client = new HttpClient();
string uploadJson = "http://mylink/WebApi/api/uploadPhoto?jsonImage=" + jsonImage + "&IdOdl=" + IdOdl + "&SnDevice=" + SnDevice + "&cod=" + cod + "&IdTechnician=" + IdTechnician + "&id_producer=" + id_producer + "&pdr=" + pdr;
client.BaseAddress = new Uri(uploadJson);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Task<HttpResponseMessage> response = client.GetAsync(uploadJson);
HttpResponseMessage res = response.Result;
if (!res.IsSuccessStatusCode)
{
Console.Write("Error upload");
}
Upvotes: 1
Views: 194
Reputation: 2982
What you are trying to do is impossible.
If you look at the RFC for the standard itself, URL / querystring lengths cannot be that long. Most implementations chop them off around 2k characters and anything over that needs to be sent via POST instead.
Upvotes: 1