"Failed to construct 'Blob': The provided value cannot be converted to a sequence" when downloading file "Failed to construct 'Blob': The provided value cannot be converted to a sequence" when downloading file ajax ajax

"Failed to construct 'Blob': The provided value cannot be converted to a sequence" when downloading file


The first parameter should be sequence.

Thus, this will not work:

let blob = new Blob(data, {    type: "application/pdf"});

But this will:

let blob = new Blob([data], {    type: "application/pdf"});


This is what I ended up with:

public HttpResponseMessage GetPdf(){    var pdf = generatePdfByteArray();    var result = Request.CreateResponse(HttpStatusCode.OK);    var dataStream = new MemoryStream(pdf);    result.Content = new StreamContent(dataStream);    result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")    {        FileName = "file.pdf"    };    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");    return result;}