kbsali / php-redmine-api

A simple PHP Redmine API client, Object Oriented

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

author_id Params Not Working When Creating New Issue

maniicandy opened this issue · comments

It created an issue with the user's ID that authenticates with the API. (author_id params not working)

This is my request

 $response = $client->getApi('issue')->create([
    'project_id' => 'Test',
    'subject' => 'test from API',
    'description' => 'test api',   
	'author_id' => '12',
    'watcher_user_ids' => [],
]);

There is no author_id parameter for creating an issue, see https://www.redmine.org/projects/redmine/wiki/Rest_Issues#Creating-an-issue

The author of the issue will always be the owner of the apikey. If the owner of the apikey has admin priviliges you can use user impersonation (see also Redmine docs) to create an issue on behalf of another user.

$client->startImpersonateUser('kim'); // username of user with id 12
// all requests will now impersonate the user `kim`

$response = $client->getApi('issue')->create([
    'project_id' => 'Test',
    'subject' => 'test from API',
    'description' => 'test api',   
    'watcher_user_ids' => [],
]);

// To stop impersonation
$client->stopImpersonateUser();