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
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?
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).
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
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.