Skip to content

Commit

Permalink
Merge pull request #49 from embedcard/master
Browse files Browse the repository at this point in the history
Fix: unable to publish to confluence with null fields in the JSON
  • Loading branch information
jasminsehic authored Feb 1, 2023
2 parents e9848da + 4b84be3 commit 9016554
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/PullRequestReleaseNotes/Publishers/ConfluencePublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ private static bool PostConfluencePage(ProgramArgs programArgs, string pageTitle
Ancestors = new[] { new Ancestor() { Id = programArgs.ConfluenceReleaseParentPageId, Type = "page" } },
Body = new Body { Storage = BuildMarkdownBodyContent(markdown) }
};
return PostConfluenceContent(programArgs, page).StatusCode == HttpStatusCode.OK;
var resp = PostConfluenceContent(programArgs, page);
if (resp.StatusCode != HttpStatusCode.OK)
{
Console.Error.WriteLine($"Failed to publish to confluence: {resp.Content}");
}
return resp.StatusCode == HttpStatusCode.OK;
}

private static bool UpdateConfluencePage(ProgramArgs programArgs, Content existingPage, string markdown)
Expand Down Expand Up @@ -119,7 +124,10 @@ private static RestRequest PrepareConfluenceRequest(RestRequest request)
}
private static void AddJsonBodyToRequest(Content page, RestRequest request)
{
var json = JsonConvert.SerializeObject(page);
var json = JsonConvert.SerializeObject(page, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
request.AddParameter("application/json", json, ParameterType.RequestBody);
}
}
Expand Down

0 comments on commit 9016554

Please sign in to comment.