Core/OfficeDevPnP.Core/Utilities/HttpHelper.cs
/// <summary>
/// This helper method makes an HTTP request and eventually returns a result
/// </summary>
/// <param name="httpMethod">The HTTP method for the request</param>
/// <param name="requestUrl">The URL of the request</param>
/// <param name="accessToken">The OAuth 2.0 Access Token for the request, if authorization is required</param>
/// <param name="accept">The content type of the accepted response</param>
/// <param name="content">The content of the request</param>
/// <param name="contentType">The content  type of the request</param>
/// <param name="referer">The URL Referer for the request</param>
/// <param name="resultPredicate">The predicate to retrieve the result, if any</param>
/// <param name="requestHeaders">A collection of any custom request headers</param>
/// <param name="cookies">Any request cookies values</param>
/// <param name="retryCount">Number of times to retry the request</param>
/// <param name="delay">Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry</param>
/// <param name="userAgent">UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks"</param>
/// <param name="spContext">An optional SharePoint client context</param>
/// <typeparam name="TResult">The type of the result, if any</typeparam>
/// <returns>The value of the result, if any</returns>
This helper method makes an HTTP request and eventually returns a result
This helper method makes an HTTP request and eventually returns a result
private static TResult MakeHttpRequest<TResult>(
            string httpMethod,
            string requestUrl,
            string accessToken = null,
            string accept = null,
            object content = null,
            string contentType = null,
            string referer = null,
            Func<HttpResponseMessage, TResult> resultPredicate = null,
            Dictionary<string, string> requestHeaders = null,
            Dictionary<string, string> cookies = null,
            int retryCount = 1,
            int delay = 500,
            string userAgent = null,
            ClientContext spContext = null)
        {
            HttpResponseHeaders responseHeaders;
            return (MakeHttpRequest<TResult>(httpMethod,
                requestUrl,
                out responseHeaders,
                accessToken: accessToken,
                accept: accept,
                content: content,
                contentType: contentType,
                referer: referer,
                resultPredicate: resultPredicate,
                requestHeaders: requestHeaders,
                cookies: cookies,
                retryCount: retryCount,
                delay: delay,
                userAgent: userAgent,
                spContext: spContext
                ));
        }
private static TResult MakeHttpRequest < TResult > ( string httpMethod , string requestUrl , string accessToken = null , string accept = null , object content = null , string contentType = null , string referer = null , Func < HttpResponseMessage , TResult > resultPredicate = null , Dictionary < string , string > requestHeaders = null , Dictionary < string , string > cookies = null , int retryCount = 1 , int delay = 500 , string userAgent = null , ClientContext spContext = null ) { HttpResponseHeaders responseHeaders ; return ( MakeHttpRequest < TResult > ( httpMethod , requestUrl , out responseHeaders , accessToken : accessToken , accept : accept , content : content , contentType : contentType , referer : referer , resultPredicate : resultPredicate , requestHeaders : requestHeaders , cookies : cookies , retryCount : retryCount , delay : delay , userAgent : userAgent , spContext : spContext ) ) ; }
This helper method makes an HTTP request and eventually returns a result
This helper method makes an HTTP request and eventually returns a result
The value of the result, if any
The value of the result if any
httpMethod
string
The HTTP method for the request
The HTTP method for the request
requestUrl
string
The URL of the request
The URL of the request
accessToken
string
The OAuth 2.0 Access Token for the request, if authorization is required
The OAuth 2 . 0 Access Token for the request if authorization is required
accept
string
The content type of the accepted response
The content type of the accepted response
content
object
The content of the request
The content of the request
contentType
string
The content  type of the request
The content type of the request
referer
string
The URL Referer for the request
The URL Referer for the request
resultPredicate
Func<HttpResponseMessage, TResult>
The predicate to retrieve the result, if any
The predicate to retrieve the result if any
requestHeaders
Dictionary<string, string>
A collection of any custom request headers
A collection of any custom request headers
cookies
Dictionary<string, string>
Any request cookies values
Any request cookies values
retryCount
int
Number of times to retry the request
Number of times to retry the request
delay
int
Milliseconds to wait before retrying the request. The delay will be increased (doubled) every retry
Milliseconds to wait before retrying the request . The delay will be increased ( doubled ) every retry
userAgent
string
UserAgent string value to insert for this request. You can define this value in your app's config file using key="SharePointPnPUserAgent" value="PnPRocks"
UserAgent string value to insert for this request . You can define this value in your app ' s config file using key = " SharePointPnPUserAgent " value = " PnPRocks "
spContext
ClientContext
An optional SharePoint client context
An optional SharePoint client context
typeparam
The type of the result, if any
The type of the result if any