@@ -24,7 +24,7 @@ public function connectToJira($host, $username, $token): Client|null
2424 public function getJiraProjects (Client $ client ): array |null
2525 {
2626 try {
27- $ response = $ client ->get ('/rest/api/2 /project ' );
27+ $ response = $ client ->get ('/rest/api/3 /project ' );
2828 return json_decode ($ response ->getBody ()->getContents ());
2929 } catch (GuzzleException $ e ) {
3030 Log::error ($ e ->getTraceAsString ());
@@ -48,16 +48,21 @@ public function getJiraTicketsByProject(Client $client, $projectKeys): array|nul
4848 };
4949 $ results = [];
5050 foreach ($ projectKeys as $ projectKey ) {
51- $ response = $ client ->get ('/rest/api/2 /search?jql=project= ' . $ projectKey );
51+ $ response = $ client ->get ('/rest/api/3 /search/jql ?jql=project= ' . $ projectKey . ' &fields=*navigable ' );
5252 $ data = json_decode ($ response ->getBody ()->getContents ());
53+ $ issues = $ data ->issues ?? [];
5354 $ results [$ projectKey ] = [
54- 'total ' => $ data -> total ,
55- 'issues ' => $ formatIssues ($ data -> issues )
55+ 'total ' => count ( $ issues ) ,
56+ 'issues ' => $ formatIssues ($ issues )
5657 ];
5758 }
5859 return $ results ;
60+ } catch (\GuzzleHttp \Exception \RequestException $ e ) {
61+ $ response = $ e ->hasResponse () ? $ e ->getResponse ()->getBody ()->getContents () : 'No response ' ;
62+ Log::error ('Jira API error: ' . $ e ->getMessage () . ' | Response: ' . $ response );
63+ return null ;
5964 } catch (GuzzleException $ e ) {
60- Log::error ($ e ->getTraceAsString ());
65+ Log::error (' Jira connection error: ' . $ e ->getMessage ());
6166 return null ;
6267 }
6368 }
@@ -67,7 +72,7 @@ public function getJiraTicketDetails($host, $username, $token, $url)
6772 try {
6873 $ client = $ this ->connectToJira ($ host , $ username , $ token );
6974 $ url = explode ('/ ' , $ url );
70- $ response = $ client ->get ('/rest/api/2 /issue/ ' . $ url [sizeof ($ url ) - 1 ]);
75+ $ response = $ client ->get ('/rest/api/3 /issue/ ' . $ url [sizeof ($ url ) - 1 ]);
7176 return json_decode ($ response ->getBody ()->getContents ());
7277 } catch (GuzzleException $ e ) {
7378 Log::error ($ e ->getTraceAsString ());
0 commit comments