Project

General

Profile

Actions

Defect #16992

closed

Cannot update wiki page via REST API

Added by gianmaria romanato over 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Environment:
Redmine version 2.5.1.stable
Ruby version 2.0.0-p481 (2014-05-08) [x86_64-linux]
Rails version 3.2.17
Environment production
Database adapter Mysql2

I am trying to update the content of a wiki page via REST API but I always get an error message complaining that I am posting no content: "text field can't be blank".

I am using the following CURL invocation:

curl -X PUT http://MY-API-KEY@redmine.lan/redmine/projects/foo/wiki/bar.xml -d "<?xml version="1.0"?>
<wiki_page>
  <text>Example</text>
  <comments>Typo</comments>
</wiki_page>" 

and I get the following error message:

<?xml version="1.0" encoding="UTF-8"?><errors type="array"><error>Text field can't be blank</error></errors>

The production log shows the following:

Processing by WikiController#update as XML
  Parameters: {"<?xml version"=>"1.0?>\n<wiki_page>\n  <text>Example</text>\n  <comments>Typo</comments>\n</wiki_page>", "project_id"=>"foo", "id"=>"bar"}
  Current user: user1 (id=23)
  Rendered common/error_messages.api.rsb (0.2ms)

The error is the same, regardless of the fact that wiki page already exists or not.

Actions #1

Updated by gianmaria romanato over 10 years ago

I found out that the main page of the REST API documentation states that the content type must be specified in the request.

curl -s -H "Content-Type: application/json" -X PUT ...

Note that I also switched from XML to JSON, because when downloading wiki pages as JSON blanks are preserved (e.g. \t \n) while they are lost in XML format.

This defect should be closed as rejected.

Actions #2

Updated by gianmaria romanato over 10 years ago

  • Status changed from New to Resolved
Actions #3

Updated by Toshi MARUYAMA over 10 years ago

  • Status changed from Resolved to Closed
Actions #4

Updated by Toshi MARUYAMA over 10 years ago

  • Resolution set to Invalid
Actions #5

Updated by Alex Last about 10 years ago

we tried both JSon and XML and various content types with Redmine 2.5.2 and we always get "Text field can't be blank" error.

Actions

Also available in: Atom PDF