How to get all created requests of a customer

rest-api

#1

I am integrating service desk through API in an already build application where logged in user can create a request using “Create Customer Request API (raiseOnBehalfOf is logged in user)”. I want to make it more interactive so that logged in user can see all their requests.

This API gives me ability to get requests
https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-request-get
but not really for a particular customer because request param doesn’t ask for username. Example doesn’t help much as it doesn’t use request params.

PHP code I am using :

$url = "https://url.atlassian.net/rest/servicedeskapi/request";

                $data_str = http_build_query([
                "serviceDeskId"  => $SERVICE_DESK_ID,
                "requestTypeId"  => $REQUEST_TYPE_ID,
                "requestStatus"  => "ALL_REQUESTS"       ,
                "requestOwnership"  => "ORGANIZATION",
                "organizationId" => $id     
               ]);
$url .= "?".$data_str;
$ch = curl_init($url);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_USERPWD, $USRPWD);

                $headers = [
                    'Accept: application/json',
                    //'Content-Type: application/json'
                ];

                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                $result = curl_exec($ch);
                curl_close($ch);
                $issues = json_decode($result);
                print_r($issues);die();

#2

Hi, @jaya.

If I understand your challenge correctly, you are searching all requests from a specific creator. You can accomplish this by using the Search API. Pass a JQL like creator in (particularCustomer) to search all issues for the particular customer.
If you want a specific Service Desk project, you can add project = projectName AND creator in (particularCustomer) in the JQL.

Hope this helps.
Ian


#3

Thanks @iragudo,

Using JQL solved my problem. I used reporter instead of creator because I am generating request using raiseOnBehalfOf which becomes reporter. I didn’t know that we can use combination of jira platform & service desk api so was looking at service desk api only.