Dear Community,
I am getting the below error in Jira Service Management (v4.13) while running a post-function in ScriptRunner plugin.
c.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of 'com.atlassian.servicedesk.api.NoSuchEntityException - The request type you are trying to view does not exist.
I am trying to hit a third party REST API with the following code. Please help me understand what is wrong here:
Code :
String charset = "UTF-8";
String boundary = "------------------------" + Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value.
String CRLF = "\r\n"; // Line separator required by multipart/form-data.
int responseCode = 0;
try
{
//Set POST general headers along with the boundary string (the seperator string of each part)
HttpURLConnection connection = (HttpURLConnection) new URL(finalUrl).openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
connection.setRequestProperty("Accept", "*/*");
connection.setRequestMethod("POST");
connection.setRequestProperty( "Authorization", "Basic dsdjteeoyejepyojeyrhurji" )
OutputStream output = connection.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, charset), true);
// Send fileA - part
// Part header
writer.append("--" + boundary).append(CRLF);
writer.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + fileA.getName() + "\"").append(CRLF);
writer.append("Content-Type: application/octet-stream").append(CRLF);// + URLConnection.guessContentTypeFromName(binaryFile.getName())).append(CRLF);
writer.append(CRLF).flush();
// File data
Files.copy(fileA.toPath(), output);
output.flush();
// End of multipart/form-data.
writer.append(CRLF).append("--" + boundary + "--").flush();
responseCode = ((HttpURLConnection) connection).getResponseCode();