Is there anyone who is able to attach the file to Jira execution?

Hi,

I am trying to attach the screenshot document to jira test execution using API https:///rest/zapi/latest/attachment?entityId=&entityType=Execution. I am not sure if I am doing any mistake here. I am getting error - status 406 every time. Is there anyone who can help us?

Java code given below.

File screenshotWordDoc = new File(Constants.SCREENSHOT_FILE_PATH + executionReportNameCellValue);
Entity payload = Entity.text(screenshotWordDoc);
String screenshotWordDocPath = Constants.SCREENSHOT_FILE_PATH + executionReportNameCellValue;

String getAttachmentEntityAPI = Constants.JIRA_URL + “rest/zapi/latest/attachment?entityId=”+ testExecutionID +"&entityType=Execution";
WebResource attachmentWebResource = client.resource(getAttachmentEntityAPI);

ClientResponse tcAttachmentClientResponse = attachmentWebResource
.header(headerAuthorization, headerAuthorizationValue)
.accept(MediaType.MULTIPART_FORM_DATA)
.type(MediaType.MULTIPART_FORM_DATA)
.post(ClientResponse.class, payload.getEntity());
System.out.println("status: " + tcAttachmentClientResponse.getStatus());
System.out.println("headers: " + tcAttachmentClientResponse.getHeaders());
System.out.println(“body:” + tcAttachmentClientResponse.getEntity(String.class));