Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bad request on attempt to update Wiki page

Guennadi Filkov September 13, 2019

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
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 16, 2019

@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

Guennadi Filkov September 16, 2019

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 S likes this
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2019

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
AUG Leaders

Atlassian Community Events