Project

General

Profile

Wiki REST Api and wiki pages relationship

Added by Dmitry Makarov about 11 years ago

Is it possible to create parent-child relationship of wiki pages as described in RedmineWikis via REST Api? I checked out this wiki Rest_WikiPages and did not found anything like this.


Replies (3)

RE: Wiki REST Api and wiki pages relationship - Added by Paresh Patel almost 11 years ago

hi dmitry

Using the REST API with cURL

curl is a command-line tool for transferring data using various protocols. It can be used to interact with the Redmine REST API.
Edit
Using JSON

Here is a simple example of a command that can be used to update an issue:

curl -v -H "Content-Type: application/json" -X PUT --data "@388.json" -u login:password http://redmine/issues/388.json
curl -v -H "Content-Type: application/json" -X PUT --data "@388.json" -H "X-Redmine-API-Key: xxxx" http://redmine/issues/388.json

The file that contains the data sent to Redmine (388.json in the example above) would look like this:

{
"issue": {
"subject": "subject123",
"notes": "Changing the subject"
}
}

Note: it's required to set the Content-Type header according to the format of the data you are sending. It must be set to one the following values:

application/json
application/xml

Edit
Using XML

Here is a simple example of a command that can be used to create an issue with custom fields:

curl -v -H "Content-Type: application/xml" -X POST --data "@issue.xml" -u login:password http://redmine/issues.xml
curl -v -H "Content-Type: application/xml" -X POST --data "@issue.xml" -H "X-Redmine-API-Key: xxxx" http://redmine/issues.xml

Where issue.xml content is:


<issue>
<subject>API custom fields</subject>
<project_id>1</project_id>
<tracker_id>2</tracker_id>
<custom_fields type="array">
<custom_field>
<id>2</id>
<value>Fixed</value>
</custom_field>
<custom_field>
<id>1</id>
<value>0.8.2</value>
</custom_field>
</custom_fields>
</issue>

Edit
Attaching files

If you want to create an issue with image.png attached, you need to upload this file first:

curl --data-binary "@image.png" -H "Content-Type: application/octet-stream" -X POST -u login:password http://redmine/uploads.xml

  1. 201 response
    <upload>
    <token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
    </upload>

Then, use the token to create the issue:

curl -v -H "Content-Type: application/xml" -X POST --data "@issue.xml" -u login:password http://redmine/issues.xml

Where issue.xml content is:


<issue>
<subject>Issue with attachment</subject>
<project_id>1</project_id>
<uploads type="array">
<upload>
<token>7167.ed1ccdb093229ca1bd0b043618d88743</token>
<filename>image.png</filename>
<content_type>image/png</content_type>
</upload>
</uploads>
</issue>

RE: Wiki REST Api and wiki pages relationship - Added by Martin Jung almost 11 years ago

Hello Dmitry,

I just tried modifying wiki using the REST API. So far it works partially. While I can get pages and delete pages (according to the description in Rest_WikiPages).

However, updating/creating does not work. It always returns 422 "Text field can't be blank".

As to your original question: I think you may want to set
<parent title="HelloWorldPage"/>

If you have feedback to the create/update issue, I would be glad to hear it.

Best regards,
Martin

RE: Wiki REST Api and wiki pages relationship - Added by Alex Last over 9 years ago

yeah, we ran into the same problem in Redmine Java API.

    (1-3/3)