php-JiraCloud-RESTAPI icon indicating copy to clipboard operation
php-JiraCloud-RESTAPI copied to clipboard

Deprecation of search enpoints

Open briavers opened this issue 10 months ago • 4 comments

As declared in https://developer.atlassian.com/changelog/#CHANGE-2046

the /search endpoints will be removed as of may 1st Is there any plan for an update?

briavers avatar Mar 07 '25 07:03 briavers

The endpoints to use now are GET or POST of /rest/api/3/search/jql. I only just became aware of this so I'm scrambling for a replacement if this library doesn't yet support it.

herbdool avatar Apr 22 '25 17:04 herbdool

I created a PR which works for my use case: https://github.com/lesstif/php-JiraCloud-RESTAPI/pull/97. It works with a simple JQL.

Might be useful to also implement the new bulk fetch: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulkfetch-post and the count api: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-approximate-count-post

herbdool avatar Apr 23 '25 02:04 herbdool

I ended up including the bulk fetch and count. It's working for me.

herbdool avatar Apr 23 '25 14:04 herbdool

In my testing using bulkFetch() has a significant performance improvement over get(), so I hope that it also gets merged in since the new search API won't return all the necessary fields (for our use case).

bulkFetch(): 0.04s per issue; get(): 0.4s per issue. So a ten times improvement.

herbdool avatar Apr 24 '25 18:04 herbdool

@lesstif can you take a look at this PR? Does it look good or need some improvement?

herbdool avatar Jul 07 '25 18:07 herbdool

The old search API was shut down today and the library therefore broken.

Any chance we can get this PR merged sooner rather than later?

SkaveRat avatar Aug 19 '25 10:08 SkaveRat

It did not work for me. Using POST gave me wrong payload so I needed to use GET like in docs https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get

I ended up extending the IssueService with added functions

    public function searchJql(
        string $jql,
        ?string $nextPageToken = null,
        int $maxResults = 15,
        array $fields = ['*all'],
        array $expand = [],
        array $properties = [],
        bool $fieldsByKeys = false,
        bool $failFast = true,
        array $reconcileIssues = [],
    ): IssueSearchJqlResult {
        $payload = [
            'jql' => $jql,
            'nextPageToken' => $nextPageToken,
            'maxResults' => $maxResults,
            'fields' => implode(',', $fields),
            'expand' => $expand,
            'properties' => $properties,
            'fieldsByKeys' => $fieldsByKeys,
            'failFast' => $failFast,
            'reconcileIssues' => $reconcileIssues,
        ];

        $ret = $this->execGet('/search/jql', $payload);
        $json = json_decode($ret);

        return $this->json_mapper->map(
            $json,
            new IssueSearchJqlResult()
        );
    }

    public function execGet(string $context, ?array $post_data = null): string|bool
    {
        $context .= '/?' . http_build_query($post_data);

        return $this->exec($context, null, 'GET');
    }

Created this new DTO to use with it

<?php

declare(strict_types=1);

namespace App\Component\JiraDto;

class IssueSearchJqlResult
{
    private ?string $nextPageToken = null;

    /** @var \JiraCloud\Issue\Issue[] */
    private array $issues = [];

    public function getNextPageToken(): ?string
    {
        return $this->nextPageToken;
    }

    public function setNextPageToken(?string $nextPageToken): void
    {
        $this->nextPageToken = $nextPageToken;
    }

    /** @return \JiraCloud\Issue\Issue[] */
    public function getIssues(): array
    {
        return $this->issues;
    }

    /** @param \JiraCloud\Issue\Issue[] $issues */
    public function setIssues(array $issues): void
    {
        $this->issues = $issues;
    }

    public function getIssue(int $index): \JiraCloud\Issue\Issue
    {
        return $this->issues[$index];
    }
}


holas1337 avatar Aug 28 '25 09:08 holas1337

Still relevant!

Ken-vdE avatar Sep 10 '25 06:09 Ken-vdE

Idd!

arnedesmedt avatar Sep 11 '25 07:09 arnedesmedt

Works for me. Please merge this.

ilowe101 avatar Sep 16 '25 16:09 ilowe101

This worked for me too, I also went with the composer patch method for now.

I feel like hoping for any activity on this project from the maintainer is probably useless though. @herbdool you could probably create a new fork if you feel like maintaining it.

Growiel avatar Sep 17 '25 10:09 Growiel

Thanks for merging the changes, @lesstif! We will give it a try.

mzeis avatar Sep 21 '25 08:09 mzeis