Oyedepo Olufemi

Oyedepo Olufemi

  • 1.4k
  • 334
  • 29.6k

Request URI is too long

May 30 2019 6:54 PM
I'm trying to post a Base64 string to the backend for save operation.
It works for smaller base64 strings, but for large files with longer base64, i get a 'Request URI is too long'
 
here's my code:
using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(currentEnvironment);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");

                var objToSave = new FileUploadForSave();

                objToSave.FirstFileBase64 = fileUploadPayload.FirstFileBase64;
                objToSave.FirstFileName = fileUploadPayload.FirstFileName;
                objToSave.FirstFileExtension = fileUploadPayload.FirstFileExtension;
                objToSave.PointSourceAppRegRecId = fileUploadPayload.PointSourceAppRegRecId;


                HttpResponseMessage responseMessage = client.PostAsJsonAsync(endpoint, objToSave).Result;

                if (responseMessage.IsSuccessStatusCode)
                {
                    return responseMessage.Content.ReadAsAsync<FileUploadResponse>().Result;
                }

Answers (1)