It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bad request on attempt to update Wiki page Edited

Using C#

{

// Get content by page ID
PageContent pageContent = await GetContentAsync(url);

// pageContent: {Body: null, Id: "900334136", Title: "GF Test page", Type: "page", Version: {Number: 5}}

// new version
Version ver = pageContent.Version;
ver.Number += 1;

// Extract body
pageContent = await GetContentAsync(url + "?expand=body.storage");

// Updating just title
pageContent.Version = ver;
pageContent.Title = pageContent.Title + "QQQ";

// pageContent: {Body: {Storage: {Representation: "storage", Value "<p>some text</p>"}, Id: "900334136", Title: "GF Test pageQQQ", Type: "page", Version: {Number: 6}}

PageContent newContent = await UpdateProductAsync(url, pageContent);

// - fails with 400, "Bad request"

}

static async Task<PageContent> UpdateContentAsync(string path, PageContent content)
{
HttpResponseMessage response = await client.PutAsJsonAsync(path, content);
response.EnsureSuccessStatusCode();

// Deserialize the updated content from the response body.
content = await response.Content.ReadAsAsync<PageContent>();
return content;
}

Any ideas why it does not work?
Thanks

1 answer

0 votes

@Guennadi Filkov,

Thank you for contacting us regarding this.

Could you help us understand what this is for exactly? I see you want to update pages in Confluence using API; is this for an add-on?

You might have better luck in our Atlassian Developer Community. That community is geared towards developers working with Confluence, creating add-ons, and custom modifications. You might find that the group there has some idea about how to correct this issue.

Regards,

Shannon

Hi Shannon,
This is about automated updating of the Wiki page with current data.
I will try my luck in Dev Community.
Thank you.

Like Shannon_Spaniol likes this

Thank you for confirming, @Guennadi Filkov. I hope you find the answer you're looking for!

Regards,

Shannon

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

283 views 9 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you