web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Save file and give a link to SRC in javaScript

(0) ShareShare
ReportReport
Posted on by 299

Hi everyone,

I have a APi , that returns a file.

I wrote a piece of code to write the file and save it. But I get this Error on line 8
"- $exception {"The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."} System.FormatException"

var client111 = new RestClient("http://..../file/a2e7af2f6621f156572a717e81f2f6df");
client111.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("gateway-token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzeXN0ZW0iOiJqdWRpY2lhcnlCYWNrT2ZmaWNlIiwiY3JlYXRlVGltZSI6IjE0MDEwMjE5MDg1MTEyMDQ3IiwidXNlcklkIjoiZDQyZmZkODYtMDQxMy00NWY4LTk3ZWEtMGYwYjRjNzBhNWI2IiwidW5pcXVlRmllbGRzIjpbeyJ1c2VybmFtZSI6ImFkbWluIn1dLCJkYXRhIjoiYWRtaW4ifQ.jkOIE104yo42FC6Lqv700f2sL4MmQfRgyvsTyQRwn4o");
request.AddHeader("Cookie", "token=fa378724f8301652788469325");
IRestResponse response = client111.Execute(request);
//Console.WriteLine(response.Content);
byte[] byteArrayPart = Convert.FromBase64String(response.Content);

const string fileNamePart = "C:\\Image\\image88.png";
byte[] dataArray = byteArrayPart;
using (FileStream fileStream = new FileStream(fileNamePart, FileMode.Create))
{
    // Write the data to the file, byte by byte.
    for (int i = 0; i < dataArray.Length; i  )
    {
        fileStream.WriteByte(dataArray[i]);
    }

}

The response model is like this:

6114.result.png

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans