I'm trying to Post RestAPI with form-data content in Groovy.
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
multipartEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("nationality", new StringBody("0082410999"));
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost postRequest = new HttpPost();
//////An error occurs on this line
postRequest.setEntity(multipartEntity.build())
Please help about this Error :
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.http.entity.mime.MultipartFormEntity@ee2abaf' with class 'org.apache.http.entity.mime.MultipartFormEntity' to class 'org.apache.http.HttpEntity'
Thanks a lot, Ali