From 21d4f80acaeee274b98a323564ab77e9fb1cf5b4 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Mon, 14 Jul 2025 17:33:44 +0530 Subject: [PATCH 1/2] fix: token issue --- CHANGELOG.md | 6 ++++++ Contentstack.Core/Models/Query.cs | 22 ++++++++++++++++++++-- Directory.Build.props | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b0d61..4f1bb70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### Version: 2.22.2 +#### Date: July-14-2025 + +##### Fix: +- Fixed token issue for Live Preview + ### Version: 2.22.1 #### Date: June-13-2025 diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 252cd42..b864a46 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -1886,11 +1886,11 @@ private async Task Exec() if (this.ContentTypeInstance!=null && this.ContentTypeInstance?.StackInstance.LivePreviewConfig.Enable == true && this.ContentTypeInstance?.StackInstance.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance?.ContentTypeId && header.Key == "access_token" - && isLivePreview) + && !string.IsNullOrEmpty(this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview)) { continue; } - headerAll.Add(header.Key, (string)header.Value); + headerAll.Add(header.Key, (String)header.Value); } } @@ -1941,7 +1941,25 @@ private async Task Exec() } else { + // console.WriteLine url, mainjson and headerAll + Console.WriteLine("=========================="); + Console.WriteLine(this._Url); + + foreach (var kvp in mainJson) + { + if (kvp.Key == "live_preview") + { + Console.WriteLine("mainjson=================="); + Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}"); + } + } + Console.WriteLine("headerAll=================="); + foreach (var kvp in headerAll) + { + Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}"); + } HttpRequestHandler requestHandler = new HttpRequestHandler(this.ContentTypeInstance.StackInstance); + Console.WriteLine(_Url); var outputResult = await requestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout); return JObject.Parse(ContentstackConvert.ToString(outputResult, "{}")); } diff --git a/Directory.Build.props b/Directory.Build.props index bec8fed..cff023c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 2.22.1 + 2.22.2 From 37e206b5895bedda2785d86f56f16e1f2a4478ad Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Mon, 14 Jul 2025 17:38:37 +0530 Subject: [PATCH 2/2] fix: remove console logs --- Contentstack.Core/Models/Query.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index b864a46..c50a09e 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -1941,25 +1941,7 @@ private async Task Exec() } else { - // console.WriteLine url, mainjson and headerAll - Console.WriteLine("=========================="); - Console.WriteLine(this._Url); - - foreach (var kvp in mainJson) - { - if (kvp.Key == "live_preview") - { - Console.WriteLine("mainjson=================="); - Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}"); - } - } - Console.WriteLine("headerAll=================="); - foreach (var kvp in headerAll) - { - Console.WriteLine($"Key: {kvp.Key}, Value: {kvp.Value}"); - } HttpRequestHandler requestHandler = new HttpRequestHandler(this.ContentTypeInstance.StackInstance); - Console.WriteLine(_Url); var outputResult = await requestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout); return JObject.Parse(ContentstackConvert.ToString(outputResult, "{}")); }