Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Method not allowed / error 405 when creating a ticket by service desk API

Stephan Frank February 2, 2025

Hi,

 

I have a flutter app that is used by external customers. They shall be able to create a service desk ticket from within the app. 

I am going to use the REST API for that. Goal is to create a ticket in the service desk and set the reply address to the customer's email address. The customers do not have a jira account.

Using

https://my-id.atlassian.net/rest/servicedeskapi/request/ECS
as URL where ECS is my project and 


Future<void> _createJiraTicket({

required String summary,

required String description,

String? screenshotPath,

}) async {

final auth = base64Encode(utf8.encode('$_jiraEmail:$_jiraApiToken'));



final body = {

'serviceDeskId': '1',

'requestTypeId': '4',

'requestFieldValues': {

'summary': summary,

'description': description,

},

};

final response = await http.post(

Uri.parse(_jiraApiUrl),

headers: {
'Authorization': 'Basic $auth',
'Accept': 'application/json',
'Content-Type': 'application/json',
},

body: jsonEncode(body),

);

if (response.statusCode != 201) {

throw Exception('Failed to create Jira ticket: ${response.body}');

}

}

 

to generate the request - sorry the spacing got messed up.

Unfortunately, I get error 405 in return.




Can you help?

1 answer

0 votes
Hana Kučerová
Community Champion
February 2, 2025

Hi @Stephan Frank ,

welcome to the Atlassian community!

Here's the documentation for the endpoint you need to use.

I think the problem is you are adding ECS to your URL, which means another endpoint is used. This endpoint is for GET requests, but your are sending POST, which results in 405 code (method not allowed).

Stephan Frank February 2, 2025

Hi @Hana Kučerová ,

Thank you :-)

You are right, that was the problem. 


Now, I am getting the error, that the user is unauthorized, but that is another story...


Best,

 

Stephan

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events