Skip to content

Create or update wiki page #53

@arnoarno

Description

@arnoarno

Hi,

To create or update a wiki page, you have to use PUT method instead of POST.
I remove in my case the cleanParams function because it's not present in the Wiki class nor AbstractApi and I don't need it.

/**
     * Create a new issue given an array of $params
     * The issue is assigned to the authenticated user.
     * @link http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Creating-an-issue
     *
     * @param  int|string        $project the project name
     * @param  string            $page    the page name
     * @param  array             $params  the new issue data
     * @return \SimpleXMLElement
     */
    public function create($project, $page, array $params = array())
    {
        $defaults = array(
            'text'     => null,
            'comments' => null,
            'version'  => null,
        );
        //$params = $this->cleanParams($params);
        $params = array_filter(array_merge($defaults, $params));

        $xml = new \SimpleXMLElement('');
        foreach ($params as $k => $v) {
            $xml->addChild($k, $v);
        }

        return $this->put('/projects/'.$project.'/wiki/'.$page.'.xml', $xml->asXML());
    }

PS : In my case (again ;) ) I replace

$c = 'Api'.$classes[$name];
by
$c = 'Redmine\Api'.$classes[$name];
in Client.php

BR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions