lesstif / php-jira-rest-client

PHP classes interact Jira with the REST API.
Other
510 stars 263 forks source link

error updating version of issue when using IssueField (works fine with updateFixVersions) #450

Closed wivaku closed 2 years ago

wivaku commented 2 years ago

Trying to add version to issueField, similar to the documentation.
Using v4.0.3.

<?php

require __DIR__ . '/vendor/autoload.php';

use JiraRestApi\Issue\IssueField;

$issueField = new IssueField(true);

$issueField
// ->addComponentAsString('Component-1') // works fine
->addVersionAsString(['1.0.2']) // error 400 when updating (even though the version exists)
;

$issueService = new IssueService();
$issueService->update(
    'TEST-879',
    $issueField,
    ['notifyUsers' => false]
);

// Error: CURL HTTP Request Failed: Status Code : 400, URL:https://xyz.atlassian.net/rest/api/2/issue/TEST-879?notifyUsers=0

The convenience wrapper updateFixVersions does work.

    $ret = $issueService->updateFixVersions($issueKey,
            $addVersions,
            $removeVersions,
            $notifyUsers = false
        );

But the consequence is that I have to make two calls to update each ticket.

lesstif commented 2 years ago

Hi @wivaku, Sorry for the late reply.

As you mentioned, IssueService's update method doesn't fit for a version updates. It may be inconvenient, you should use the updateFixVersions method.

Thanks!