lesstif / php-jira-rest-client

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

Field 'descriptionV3' cannot be set. It is not on the appropriate screen, or unknown. #457

Closed lucasaba closed 2 years ago

lucasaba commented 2 years ago

I'm trying to create a new Issue. I'm a cloud user and using V3 of the API.

I tried to add the description to the IssueField but Jira says that description":"Operation value must be an Atlassian Document (see the Atlassian Document Format). I then tried with IssuFieldV3.

$issueField = new IssueFieldV3();
$description = new DescriptionV3();
$description->addDescriptionContent('paragraph', $summary);
$issueField->setProjectKey($projectKey)
    ->setSummary($summary)
    ->setIssueTypeAsString('Task')
    ->addComponentsAsArray($components)
    ->setDescriptionV3($description)
;

Now it says "descriptionV3":"Field 'descriptionV3' cannot be set. It is not on the appropriate screen, or unknown."

I'm using v4.0.4 of php-jira-rest-client and PHP 8.1.2.

Could I try to "force" to use "description" label in DescriptionV3 serialization ?

lucasaba commented 2 years ago

Editing src/Issue/IssueFieldV3.php and adding the following method (really a ugly code....):

    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        $result = parent::jsonSerialize();
        $result['description'] = $result['descriptionV3'];
        unset($result['descriptionV3']);
        return $result;
    }

solves the issue.

lesstif commented 2 years ago

Hi @lucasaba, Thank you for your comments.

I changed the code based on your suggestion, could you check the code works well, please?

lucasaba commented 2 years ago

Hi @lesstif , works like a charm! Thank you very much!