Class HttpHelper
Static class full of helper methods to make HTTP requests
Inheritance
Namespace: PnP.Framework.Utilities
Assembly: PnP.Framework.dll
Syntax
public static class HttpHelper : object
Fields
JsonContentType
Declaration
public const string JsonContentType = null
Field Value
System.
|
Methods
MakeDeleteRequest(String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP DELETE request
Declaration
public static void MakeDeleteRequest(string requestUrl, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
MakeGetRequestForStream(String, String, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP GET request and returns the result as a String
Declaration
public static IO.Stream MakeGetRequestForStream(string requestUrl, string accept, string accessToken = null, string referer = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The accept header for the response |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
System. The URL Referer for the request |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
System. The Stream of the result |
MakeGetRequestForStreamWithResponseHeaders(String, String, out HttpResponseHeaders, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP GET request and returns the result as a String
Declaration
public static IO.Stream MakeGetRequestForStreamWithResponseHeaders(string requestUrl, string accept, out HttpResponseHeaders responseHeaders, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The accept header for the response |
Http The response headers of the HTTP request (output argument) |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
System. The Stream of the result |
MakeGetRequestForString(String, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP GET request and returns the result as a String
Declaration
public static String MakeGetRequestForString(String requestUrl, String accessToken = null, String accept = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
String
requestUrl
The URL of the request |
String
accessToken
The OAuth 2.0 Access Token for the request, if authorization is required |
String
accept
The value for the accept header in the request |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
String
The String value of the result |
MakePatchRequestForString(String, Object, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP PATCH request and returns the result as a String
Declaration
public static string MakePatchRequestForString(string requestUrl, object content = null, string contentType = null, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content/type of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
System. The String value of the result |
MakePostRequest(String, Object, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP POST request without a response
Declaration
public static void MakePostRequest(string requestUrl, object content = null, string contentType = null, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content/type of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
MakePostRequestForHeaders(String, Object, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP GET request and returns the result as a String
Declaration
public static HttpResponseHeaders MakePostRequestForHeaders(string requestUrl, object content = null, string contentType = null, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content type for the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
Http The Stream of the result |
MakePostRequestForString(String, Object, String, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP POST request and returns the result as a String
Declaration
public static string MakePostRequestForString(string requestUrl, object content = null, string contentType = null, string accessToken = null, string accept = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content/type of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
System. The value for the accept header in the request |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
System. The String value of the result |
MakePutRequest(String, Object, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP PUT request without a response
Declaration
public static void MakePutRequest(string requestUrl, object content = null, string contentType = null, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content/type of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
MakePutRequestForString(String, Object, String, String, Dictionary<String, String>, Dictionary<String, String>, Int32, Int32, String, ClientContext)
This helper method makes an HTTP PUT request and returns the result as a String
Declaration
public static string MakePutRequestForString(string requestUrl, object content = null, string contentType = null, string accessToken = null, Dictionary<string, string> requestHeaders = null, Dictionary<string, string> cookies = null, int retryCount = 1, int delay = 500, string userAgent = null, ClientContext spContext = null)
Parameters
System. The URL of the request |
System. The content of the request |
System. The content/type of the request |
System. The OAuth 2.0 Access Token for the request, if authorization is required |
Dictionary<System. A collection of any custom request headers |
Dictionary<System. Any request cookies values |
System. Number of times to retry the request |
System. Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry |
System. UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks" |
Client An optional SharePoint client context |
Returns
System. The String value of the result |