1

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");
        }
1
  • 4
    Depending on the exact error message you are getting, either clientside or serverside, this may differ. However, the obvious way would be to POST the image file in the body rather than do a GET through the querystring. Commented Jun 26, 2015 at 10:17

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.