I'm trying to use the jira service desk api but I couldn't call or create service desk tickets and tried everything. I am using python.
Hi @Francisco Alberto Franjul Rodríguez ,
welcome to the Atlassian Community!
Would you please share more information? How does your code looks like? Do you get any error message? Which one? etc.
Thank you.
Hello @Hana Kučerová
Thanks for reaching out!
I am making an integration that can read and write tickets made with servicedesk.
I tryed using the documentation about integrating with servicedesk but It all seems to be deprecated.
Since there seems to be no updated documentation I don't know which method to call in order to read created servicedesk tickets or create new ones.
This is the code.
from urllib.error import HTTPError
import json
from atlassian import ServiceDesk
_serviceDesk = ServiceDesk(
url='https://penadefillo.atlassian.net/',
username=*****@*****.com',
password='*****')
# get service desk with ID
# data = _serviceDesk.get_service_desk_by_id(5)
#print(data)
#GET client request
# data = _serviceDesk.get_my_customer_requests()
#print(data)
# Metodo para obtener los usuarios en la organizacion pero no se usa en la empresa
#data = _serviceDesk.get_users_in_organization(1,limit=100)
#print(data)
#Comment attachement
#print(data)
# def post():
# data = _serviceDesk.create_attachment(
# service_desk_id=5,
# filename='/Users/franciscoalbertofranjul/Downloads/IMG_5650.JPG',
# issue_id_or_key='RRHH-448',
# public=True,
# comment='Probando Service Desk desde Python'
# )
# return data
#
# data = _serviceDesk.create_request_type(
# service_desk_id=5,
# request_description='Este request esta siendo probado desde python',
# request_name='Probando el serivcio desde Python',
# request_type_id='',
# request_help_text='',
# )
# return data
# print(post())
#create comment
#data = _serviceDesk.create_request_comment('RRHH-217',body="Estoy probando la API de Python", public=True)
#data = _serviceDesk.create_customer_request(5, 'RRHH-330', None, None)
#data = _serviceDesk._create_oauth2_session('https://auth.atlassian.com/authorize?audience=api.atlassian.com&client_id=iKWgVmjcufHV2YmuoU9HqyfM5NI4eJhT&scope=read%3Aservicedesk-request%20manage%3Aservicedesk-customer&redirect_uri=https%3A%2F%2Fpenadefillo.atlassian.net%2Fjira%2Fservicedesk&state=${YOUR_USER_BOUND_VALUE}&response_type=code&prompt=consent')
#data = _serviceDesk.get_service_desk_by_id(5)
#print(data)
# data = _serviceDesk.create_request_type(
# request_type_id=17,
# service_desk_id=5,
# request_description='Probando el Jira Service Desk Python Api',
# request_name='Solicitud de Vacaciones',
# request_help_text='Probando el Jira Service Desk Python Api')
#
# print(data)
# def create_request_type(
# self,
# service_desk_id,
# request_type_id,
# request_name,
# request_description,
# request_help_text,
# ):
# data = {
# "Vacaciones": request_type_id,
# "Vacaciones Prueba": request_name,
# "Probando api": request_description,
# "helpText": request_help_text,
# }
#
# url = "rest/servicedeskapi/servicedesk/{}/requesttype".format(service_desk_id)
#
# return self.post(url, data=data, headers=self.experimental_headers)
# def raise_for_status(self, response):
# if 400 > response.status_code or response.status_code >= 600:
# return
# try:
# j = response.json()
# error_msg = j["errorMessage"]
# except Exception:
# response.raise_for_status()
#
# raise HTTPError(error_msg, response=response)
# data = _serviceDesk.create_customer_request(service_desk_id=5,
# request_type_id='RRHH',
# values_dict='Probando el Servicio',
# raise_on_behalf_of=None,
# request_participants=None)
# print(json.dumps(json.loads(data), sort_keys=True, indent=4, separators=(",", ": ")))
#Get service
# data= _serviceDesk.get_request_types(5)
# print(json.dumps(data,sort_keys=True,indent=4))
data= _serviceDesk.get_my_customer_requests()
print(json.dumps(data,sort_keys=True,indent=4))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Francisco Alberto Franjul Rodríguez ,
thank you for sharing the code.
According to the documentation when you are trying to work with cloud Service Desk, the authentication should look like this:
service_desk = ServiceDesk( url='https://your-domain.atlassian.net', username=jira_username, password=jira_api_token, cloud=True)
So you need to generate API token instead of use your password and then add the parameter cloud = True. Please try. Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how i can call all ticket service desk?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Francisco Alberto Franjul Rodríguez ,
it is not very clear what you mean by "all ticket service desk".
According to the Jira Service Desk module documentation, the only possibility is to get customer requests using
service_desk.get_my_customer_requests()
(customer is the user, who is used for authentication).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
'import os 'import requests 'from flask import Flask 'from flask_restful import Resource, Api 'import json 'url = f"{os.getenv('BASE_URL')}/issue" 'headers = { "Accept": "application/json", "Content-Type": "application/json" } 'class JiraIssueCreate(Resource): def get(self): response = requests.post( url, headers=headers, data=payload, auth=( os.getenv("JIRA_USER"), os.getenv("JIRA_TOKEN") ) )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @jaime.heria ,
I'm sorry, but this is something I really don't know. I would recommend you to ask a new question here in the community, so that another people here would be able to help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.