From 20168cc44b4c4c3bfc2aeb3d33f66afc758840c9 Mon Sep 17 00:00:00 2001 From: Andrew Hickey Date: Wed, 15 Jun 2022 14:12:13 -0700 Subject: [PATCH 1/2] Add Header option to SObjectDescribeFull to allow for If-Modified-Since header (as per https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/sobject_describe_with_ifmodified_header.htm ) --- src/NetCoreForce.Client/ForceClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NetCoreForce.Client/ForceClient.cs b/src/NetCoreForce.Client/ForceClient.cs index f8bea80..5764891 100644 --- a/src/NetCoreForce.Client/ForceClient.cs +++ b/src/NetCoreForce.Client/ForceClient.cs @@ -597,14 +597,15 @@ public async Task GetObjectBasicInfo(string objectTypeName) /// Use the SObject Describe resource to retrieve all the metadata for an object, including information about each field, URLs, and child relationships. /// /// SObject name, e.g. Account + /// Example If-Modified-Since: Wed, 3 Jul 2013 19:43:31 GMT /// Returns SObjectMetadataAll with full object meta including field metadata - public async Task GetObjectDescribe(string objectTypeName) + public async Task GetObjectDescribe(string objectTypeName, Dictionary customHeaders = null) { var uri = UriFormatter.SObjectDescribe(InstanceUrl, ApiVersion, objectTypeName); JsonClient client = new JsonClient(AccessToken, _httpClient); - return await client.HttpGetAsync(uri); + return await client.HttpGetAsync(uri, customHeaders); } /// From 50910a581e1e3537dd22bbcfe3bde1ec0676f0bd Mon Sep 17 00:00:00 2001 From: Andrew Hickey Date: Thu, 16 Jun 2022 11:59:29 -0700 Subject: [PATCH 2/2] I've added this change to handle the response returned when If-Modified-Since header used. --- src/NetCoreForce.Client/JsonClient.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NetCoreForce.Client/JsonClient.cs b/src/NetCoreForce.Client/JsonClient.cs index 7721b0f..e647ead 100644 --- a/src/NetCoreForce.Client/JsonClient.cs +++ b/src/NetCoreForce.Client/JsonClient.cs @@ -192,6 +192,15 @@ private async Task GetResponse(HttpRequestMessage request, Dictionary(string.Empty); } + // returned when header If-Modified-Since used and the object requested wasn't modified since provided date + if (responseMessage.StatusCode == HttpStatusCode.NotModified) + { + if (customHeaders != null && customHeaders.ContainsKey("If-Modified-Since")) + { + return JsonConvert.DeserializeObject(string.Empty); + } + } + //sucessful response, skip deserialization of response content if (responseMessage.IsSuccessStatusCode && !deserializeResponse) {