# How to generate reusable C# RestSharp code

**URL:** <https://community.postman.com/t/how-to-generate-reusable-c-restsharp-code/13822>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [July 1, 2020, 7:31pm UTC](https://community.postman.com/t/how-to-generate-reusable-c-restsharp-code/13822 "2020-07-01T19:31:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zydjohn](https://avatars.discourse-cdn.com/v4/letter/z/91b2a8/32.png) [@zydjohn](https://community.postman.com/u/zydjohn)\
**Post date:** [July 1, 2020, 7:31pm UTC](https://community.postman.com/t/how-to-generate-reusable-c-restsharp-code/13822/1 "2020-07-01T19:31:48Z")

</div>

Hello:  
I have used Postman for a while, its user interface looks good. But now, I need to go one step further. I want to visit one web page: [https://www.betonline.ag/sportsbook/soccer/todaygames](https://www.betonline.ag/sportsbook/soccer/todaygames)  
From my testing, I think this web page has some settings to prevent bot to visit, so I have to add at least the following headers: Accept, Accept-Language, Connection and User-Agent.  
However, at first run, the HTTP Get request failed, I got 302 forbidden by cloudflare server.  
But after I change cookies settings, then Postman can accept the cookies by cloudflare server, I can use HTTP Get to see the web page contents.  
Since I need to use C# code to visit this page every day, I need a reusable C# code, but the following C# RestSharp code generated by Postman is definitely not reusable:  
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
var client = new RestClient(“[https://www.betonline.ag/sportsbook/soccer/todaygames](https://www.betonline.ag/sportsbook/soccer/todaygames)”);  
client.Timeout = -1;  
var request = new RestRequest(Method.GET);  
request.AddHeader(“Accept”, “text/html,application/xhtml+xml,application/xml;q=0.9,image/apng,_/_;q=0.8”);  
request.AddHeader(“Accept-Language”, “en-GB”);  
request.AddHeader(“Connection”, “keep-alive”);  
client.UserAgent = “Mozilla/5.0 (X11; Linux x86\_64) AppleWebKit/537.36 (KHTML, like Gecko; Google Page Speed Insights) Chrome/27.0.1453 Safari/537.36”;  
request.AddHeader(“Cookie”, “\_\_cfduid=d0b759ddd2fd299d2f2c9de03c4b0fc831593630928; ASP.NET\_SessionId=zmbl3m55wabw5xzhpwg2hoii; KW\_Search=domain=&kw=&HTTP\_Refer=; UDeepLink=soccer/todaygames; THE\_COOKIE=!ef7wV0H9Y9t2yIxPZwurU0T9hxdEzJFAztB+RpjU4Uz8zPZlOuVGRJLwhs0xfqY4iW2I0Y//6upBQL0=; \_\_cf\_bm=f377f88979eb854414f241a9d4a4278d7b21b57d-1593630929-1800-AcjtwRqjj28AHCeQxzs2XKTQv4ylFCKQxDbO8j63ozFZB20Qn8M/HURpnvtpQHCeUZHEEWCbbd6q86ikys3FDWg=; \_\_cfruid=4fe1f54b6a72e832bfd73e54a7f789635e6302e7-1593630929”);  
IRestResponse response = client.Execute(request);  
Console.WriteLine(response.Content);  
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
I want to know how to get the cookies set by cloudflare and reuse C# code, so I can visit the web page as long as I wish.  
Thanks,
