"Client must be authenticated to access this resource" / Error 401 for REST API call with basic auth

Stephan Frank
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!
February 3, 2025

Dear all,

 

I have a flutter app deployed to external customers. These customers shall be able to raise a support ticket from within the app. I have the name and email address of the customer and want to use that as reply to - data for the request. 

Behind the scene, I am calling 

https://my-org-name.atlassian.net/rest/servicedeskapi/request
with basic authentication.  I have generated a API key with my jira user and authenticate with that token and email address. 
Future<void> _createJiraTicket({
required String summary,
required String description,

}) 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}');
}

}
That returns a 401 Unauthorized error. 

I set Create Issues permission to public and my user has the roles "Administrators", "Service Desk Customers" and " Service Desk Team". 

a) Can you give a hint, what I have to change in order to be able to create a service desk issue.
b) If anyone has an idea how to set the user's name and email to the ticket in a way that I can click on the "reply to customer" button in service desk and the reply is send to his address please let me know.

Best,
Stephan

1 answer

0 votes
Stephan Frank
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!
February 3, 2025

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