OutOFMemoryException in reading large data from REST api

382 views
Skip to first unread message

Gopal Shinde

unread,
May 12, 2019, 3:43:22 AM5/12/19
to RestSharp

hi all

I am facing difficulty in reading large data from REST api.

in My C# code, I am using RESTClient to read from API

=============================================

RestClient client = new RestClient(Uri);
                RestRequest request = new RestRequest(Method.GET);
                request.AddHeader("Accept", "application/zip");
                request.AddHeader("authorization", $"apikey {apiKey}");

                IRestResponse response = await Task.Run(() => client.Execute(request));
                ResponseResult.RawBytes = response.RawBytes;
                ResponseResult.Data = ToReferenceData(new MemoryStream(response.RawBytes));

=================================================

REST api returns 175 MB zip file. So the above code always fails with OutOfMemoryException

Any idea how to get this working?

I have tried HTTPClient, as well as memoryStream but didnt work.

Please help if anybody knows how to get around this.

thanks,

Gopal



dharmesh sharma

unread,
Jun 6, 2019, 11:32:45 PM6/6/19
to rest...@googlegroups.com
You have to get data in chunks that’s solved you’ problem 

--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/restsharp/a44591c0-0f47-4f82-8fb4-7d1e5e28b748%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Thanks & Regard
Dharmesh Sharma
9911086355


Reply all
Reply to author
Forward
0 new messages