Add watcher_user_id
phungthuan99 opened this issue · comments
I want to add watcher_user_id, what should I do?
and i tried using this function inside file Redmine/Api/Issue.php but it doesn't work
public function addWatcher($id, $watcherUserId) { return $this->post('/issues/'.$id.'/watchers.xml', '<user_id>'.$watcherUserId.'</user_id>'); }
my code
$client->getApi('issue')->addWatcher($issue_id,$watcher_user_id);
thanks
Please try this: (untested)
$client->getApi('issue')->update($issueId, [
'watcher_user_ids' => [
$watcher_user_id
],
]);
Please try this: (untested)
$client->getApi('issue')->update($issueId, [ 'watcher_user_ids' => [ $watcher_user_id ], ]);
Thanks, But I tried it but it still doesn't work
:((
Please try this: (untested)
$client->getApi('issue')->update($issueId, [ 'watcher_user_ids' => [ $watcher_user_id ], ]);
Thanks, But I tried it but it still doesn't work
:((
this is my code, can you check it for me
$issue_id = $_REQUEST['issue_id'];
$id_user_watcher = $_REQUEST['id_user_watcher'];
$client->getApi('issue')->update($issue_id, [
'watcher_user_ids' => [
$id_user_watcher
],
]);
I console.log it still get working and value, but after execute getApi it gives error
The Redmine docs tells:
Adding a watcher
Added in 2.3.0
POST /issues/[id]/watchers.[format]
Parameters:
user_id
(required): id of the user to add as a watcher
But for me it is unclear how to set the required user_id
. Could someone help me?
Hey @phungthuan99, I just tested adding a watcher to an issue with this code:
$client->getApi('issue')->addWatcher($issueId, $userId);
The code works as expected. Please make sure that
- the
$issueId
and$userId
are correct - the user has the permission to watch the issue
- you are using Redmine 2.3 or newer