Skip to content

🔗✔CustomHTTPRequest is a .NET library to create an HTTP request when consuming a Web Service or REST API.

License

Notifications You must be signed in to change notification settings

pix3lize/CustomHTTPRequest

Repository files navigation

CustomHTTPRequest

Nuget GitHub repo size GitHub issues

HTTP Request wrapper library to create REST API request, Web Request to upload file, and Web Request with basic authentication. CustomHTTPRequest come with the functionality to save cookies into cookies container.

Usage

HTTP GET request

Please find the sample code :

CustomHTTPRequest CRequest = new CustomHTTPRequest(); 
CustomWebResponse CResponse = new CustomWebResponse();
	
CResponse = CRequest.HTTPCustomRequest("https://www.google.com");
	
//GET  https://www.google.com 200 OK
Console.WriteLine(CResponse.Method + "  " + 
    CResponse.UrlRequest + " " + 
    CResponse.StatusCode + " " +
    CResponse.Status);
	
//Time taken : 00:00:00:05
Console.WriteLine("Time taken : " +CResponse.TimeTaken); 

//Result:
//GET  https://www.google.com 200 OK
//Time taken : 00:00:00:12

HTTP POST with cookies container

  • Login to a website
  • Save the authentication cookies
  • Download the file
CustomHTTPRequest CRequest = new CustomHTTPRequest();
CustomWebResponse CResponse = new CustomWebResponse();
CookieContainer CContainer = new CookieContainer();

//Login to website and store the authentication session.
CResponse = CRequest.HTTPCustomRequest("https://docushare.xerox.com/doug/dsweb/ApplyLogin", "[email protected]&password=password&domain=DocuShare&Login=Login", ref CContainer);

// Download file and save it into file 
CRequest.ReturnStream = true;
CResponse = CRequest.HTTPCustomRequest(@"https://docushare.xerox.com/doug/dsweb/Get/Document-121470", CContainer);

CResponse.SafeToFile(@"download2.pdf");

REST API

Send REST API request with JWT token

//REST API Sample 
RESTRequest RRequest = new RESTRequest();
CResponse = new CustomWebResponse();

CResponse = RRequest.RESTBearer(@"https://api.sandbox.finance.tech/v1/profiles", RESTRequest.Method.GET, "","{{JWT token}}");

About

🔗✔CustomHTTPRequest is a .NET library to create an HTTP request when consuming a Web Service or REST API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages