This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-5d7b5a77-d803-490f-a14a-44e23169691e XWIKI-22337 Open

Updating just the hidden property is impossible via the REST API

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-48462ab5-7de9-4bad-a2d5-0e022b91a59a Michael Hamann created this issue on 17/Jul/24 11:47
 
Summary: Updating just the hidden property is impossible via the REST API
Issue Type: cid:jira-generated-image-avatar-5d7b5a77-d803-490f-a14a-44e23169691e Bug
Affects Versions: 7.3
Assignee: Unassigned
Components: REST
Created: 17/Jul/24 11:47
Priority: cid:jira-generated-image-static-major-3d580c7d-634f-4b0d-883a-7d55e3752541 Major
Reporter: Michael Hamann
Description:

Steps to reproduce:

  1. Create a (non-hidden) page
  2. Execute the following JavaScript snippet in the browser's console:
    fetch(require('xwiki-meta').restURL, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      },
      body: JSON.stringify({
        hidden: true
      })
    })
    .then(response => response.json())
    .then(json => {
      console.log('Response:', json);
    })
    .catch(error => {
      console.error('Error sending PUT request:', error);
    });
    

Expected result:

The page is now hidden and the updated page is logged.

Actual result:

The page hasn't been updated and an error "Error sending PUT request: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data" is logged because the response is empty (status 304 not modified). This is very related to XWIKI-22336 as while the code always applies the hidden property, it never marks the document as modified after changing it.

As a workaround, any property like the title can be specified with the same value as returned by the REST API, then the document is correctly updated.