Hi
we run a groovy script to create projects from a jira issue in a workflow post function via RestAPI "createshared". The script runs fine as long as the project name doesn't contain german special character (Umlauts). Then the following error is thrown:
Uncaught exception thrown by REST service: Invalid UTF-8 middle byte 0xe4
Here is my code snippet:
final String PROJECT_NAME_TO_CREATE = "ÄäÖöÜüß"
final String PROJECT_LEAD_USERNAME = issue.reporter.name //Reporter wird Project Lead
def cField5Object = customFieldManager.getCustomFieldObjectsByName('Produkt + Template')
def cField5 = cField5Object[0]
def cFieldValue5 = issue.getCustomFieldValue(cField5)
def String template = String.valueOf(cFieldValue5).drop(14);
final String PROJECT_TEMPLATE = template.substring(0,template.length() - 1)
// Projekt Beschreibung wird der Template Name eingefügt
final String PROJECT_DESCRIPTION = "Basierend auf Template: " + PROJECT_TEMPLATE
projectTemplateID = 20925
ProjectManager projectManager = ComponentAccessor.getProjectManager()
Project templateProjectId = projectManager.getProjectByCurrentKey(projectTemplateKey);
//StringEntity stringEntity = new StringEntity('{"key":"RYMG","name":"Rest Ye Merry Gentlemen","lead":"XV13499"}')
def propertyString = '{"key":"' + PROJECT_KEY_TO_CREATE + '","name":"' + PROJECT_NAME_TO_CREATE + '","lead":"' + PROJECT_LEAD_USERNAME + '","description":"' + PROJECT_DESCRIPTION + '"}'
StringEntity stringEntity = new StringEntity(propertyString)
log.warn("stringEntity: " + propertyString)
HttpPost httpPost = new HttpPost(JIRA_BASEURL + "/rest/project-templates/1.0/createshared/" + projectTemplateID)
log.warn("HttpPost = " + JIRA_BASEURL + "/rest/project-templates/1.0/createshared/" + projectTemplateID)
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json")
httpPost.setEntity(stringEntity)
//httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic dXNlcjpwd2Q=")
httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic ${authString}")
HttpClient httpClient = HttpClientBuilder.create().build()
HttpResponse response = httpClient.execute(httpPost)
The RestAPI with curl directly from the commandline works perfect.
Any ideas
Peter