Class HttpUtil
Namespace: Workspace.XBR.Xperiflow.Utilities.Http
Assembly: Xperiflow.dll
public static class HttpUtil
Methods
ExtractWebResponseAsJsonObject(SessionInfo, ref HttpResponseMessage)
Extracts the content that exists within a WebResponse as a JObject. Note that there are side effects on this webResp object. See parameter for details.
public static JObject? ExtractWebResponseAsJsonObject(SessionInfo si, ref HttpResponseMessage response)
Returns
Newtonsoft.Json.Linq.JObject
JObject - Note that null will be returned in the event that the WebResponse is null.
Parameters
Type | Name | Description |
---|---|---|
OneStream.Shared.Common.SessionInfo | si | |
System.Net.Http.HttpResponseMessage | response | Note that there are side effects on this object. This will extract the response content from the web response. |
ExtractWebResponseAsString(SessionInfo, ref HttpResponseMessage)
Extracts the content that exists within a WebResponse as a String. Note that there are side effects on this webResp object. See parameter for details.
public static string ExtractWebResponseAsString(SessionInfo si, ref HttpResponseMessage response)
Returns
System.String
String - Note that an empty string will be returned in the event that the WebResponse is null.
Parameters
Type | Name | Description |
---|---|---|
OneStream.Shared.Common.SessionInfo | si | Session information. |
System.Net.Http.HttpResponseMessage | response | Note that there are side effects on this object. This will extract the response content from the web response. |
GetJsonObjectFromJsonString(SessionInfo, string)
Converts a JSON-formatted string to a JObject.
public static JObject? GetJsonObjectFromJsonString(SessionInfo si, string jsonString)
Returns
Newtonsoft.Json.Linq.JObject
A JObject representation of the JSON string, or null if the string is empty or invalid.
Parameters
Type | Name | Description |
---|---|---|
OneStream.Shared.Common.SessionInfo | si | The session information. |
System.String | jsonString | The JSON-formatted string to convert. |
BuildWebQueryParameterString(SessionInfo, Dictionary<string, object>)
public static string BuildWebQueryParameterString(SessionInfo si, Dictionary<string, object> queryParams)
Returns
System.String
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Collections.Generic.Dictionary<System.String,System.Object> | queryParams |
BuildUri(SessionInfo, Uri, string, object[]?, Dictionary<string, object>?)
public static Uri BuildUri(SessionInfo si, Uri baseUri, string relativeUri, object[]? urlParams = null, Dictionary<string, object>? queryParams = null)
Returns
System.Uri
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Uri | baseUri |
System.String | relativeUri |
System.Object[] | urlParams |
System.Collections.Generic.Dictionary<System.String,System.Object> | queryParams |
BuildBodyParams(SessionInfo, string, Encoding?, string)
public static StringContent? BuildBodyParams(SessionInfo si, string bodyParams, Encoding? encoding = null, string mediaType = "application/json")
Returns
System.Net.Http.StringContent
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.String | bodyParams |
System.Text.Encoding | encoding |
System.String | mediaType |
BuildBodyParams(SessionInfo, JObject, Encoding?, string)
public static StringContent? BuildBodyParams(SessionInfo si, JObject bodyParams, Encoding? encoding = null, string mediaType = "application/json")
Returns
System.Net.Http.StringContent
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
Newtonsoft.Json.Linq.JObject | bodyParams |
System.Text.Encoding | encoding |
System.String | mediaType |
BuildBodyParams(SessionInfo, Dictionary<string, object>, Encoding?, string)
public static StringContent? BuildBodyParams(SessionInfo si, Dictionary<string, object> bodyParams, Encoding? encoding = null, string mediaType = "application/json")
Returns
System.Net.Http.StringContent
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Collections.Generic.Dictionary<System.String,System.Object> | bodyParams |
System.Text.Encoding | encoding |
System.String | mediaType |
ExecuteWebServiceRequest(SessionInfo, HttpClient, HttpRequestMessage, bool, bool)
public static HttpResponseMessage ExecuteWebServiceRequest(SessionInfo si, HttpClient client, HttpRequestMessage requestMsg, bool raiseOnFailedStatus = true, bool logErrors = true)
Returns
System.Net.Http.HttpResponseMessage
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Net.Http.HttpClient | client |
System.Net.Http.HttpRequestMessage | requestMsg |
System.Boolean | raiseOnFailedStatus |
System.Boolean | logErrors |
RequestHttpClient(SessionInfo, HttpClient, HttpRequestMessage, TimeSpan, int, bool, bool)
public static HttpResponseMessage RequestHttpClient(SessionInfo si, HttpClient client, HttpRequestMessage requestMsg, TimeSpan retryInterval, int maxRetries = 3, bool raiseException = true, bool logError = true)
Returns
System.Net.Http.HttpResponseMessage
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Net.Http.HttpClient | client |
System.Net.Http.HttpRequestMessage | requestMsg |
System.TimeSpan | retryInterval |
System.Int32 | maxRetries |
System.Boolean | raiseException |
System.Boolean | logError |
RequestHttpClientWithRetry(SessionInfo, HttpClient, HttpRequestMessage, TimeSpan, int)
public static HttpResponseMessage RequestHttpClientWithRetry(SessionInfo si, HttpClient client, HttpRequestMessage requestMsg, TimeSpan retryInterval, int maxRetries = 3)
Returns
System.Net.Http.HttpResponseMessage
Parameters
Type | Name |
---|---|
OneStream.Shared.Common.SessionInfo | si |
System.Net.Http.HttpClient | client |
System.Net.Http.HttpRequestMessage | requestMsg |
System.TimeSpan | retryInterval |
System.Int32 | maxRetries |
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object,System.Object)
System.Object.GetHashCode
System.Object.GetType
System.Object.MemberwiseClone
System.Object.ReferenceEquals(System.Object,System.Object)
System.Object.ToString