How to use service desk method create_customer_request corret

Markus Hofmann
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 8, 2024

Hi, 

I read the API of create_customer_request but it does not show how to use it.

My first question how to use customized fields inside a dropdown list?

 

service_desk_id = "13",
request_type_id = "815"
request_field_values = {
"summary": summary,
"customfield_17000": {"value": "dropDownValue"},
"description": description
}

request = self.service_desk.create_customer_request(service_desk_id, request_type_id, request_field_values)

 

My last question is: How do I get the issue key from the response?

Do you have an example?

 

Thanks,

Markus

1 answer

0 votes
Maycon Ritzmann
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 21, 2024

Here's an example:

def create_jira_issue(self, issue_info_dict, user_info, slack_thread):

"""

Creates a new Jira issue based on the provided information.

Parameters:

- issue_info_dict (dict): A dictionary containing the following keys:

- 'request_type' (str): The ID of the request type for the issue.

- 'summary' (str, optional): A short summary of the issue (default is '').

- 'technology' (str): The technology related to the issue (e.g., server, database).

- 'environment' (str): The environment related to the issue (e.g., production, development).

- 'service name' (str, optional): The name of the service related to the issue (default is '').

- 'classification' (str, optional): The classification of the issue (e.g., critical, high) (default is '').

- user_info (dict): A dictionary containing user information. It should include:

- 'profile' (dict): A dictionary containing user profile information.

- 'email' (str): The email address of the user.

- slack_thread (str): The ID of the Slack thread associated with the issue. This is used to format the Jira issue description and associate it with the corresponding Slack conversation.

Returns:

- dict or None: Returns the newly created Jira issue as a dictionary if successful, or None if an error occurs.

"""

user_email = user_info['profile']['email']

service_desk_id = jira_settings.JIRA_PORTAL_ID

request_type_id = issue_info_dict.get('request_type')

service_name = issue_info_dict.get('service name') if issue_info_dict.get('service name') is not None else ""

classification = issue_info_dict.get('classification') if issue_info_dict.get('classification') is not None else ""

issue_dict = {

'serviceDeskId': service_desk_id,

'requestTypeId': request_type_id,

'requestFieldValues': {

'summary': issue_info_dict.get('summary', ''),

'description': self.__format_jira_issue_description(issue_info_dict, slack_thread),

'customfield_10374': issue_info_dict['technology'],

'customfield_10376': issue_info_dict['environment'],

'customfield_10375': service_name,

'customfield_10391': classification,

}

}

try:

new_issue = self.client.create_customer_request(fields=issue_dict)

logger.info(f'New Jira issue created: {new_issue}')

return new_issue

except Exception as e:

logger.error(f'Error creating Jira issue: {e}')

return None

Suggest an answer

Log in or Sign up to answer