Multiple request params with infrahttpclient?

I'm trying to make a POST to an endpoint with two RequestParams using the Infrahttpclient. I'm attempting to use the InfraMultipartPostMethod to do this and will provide sample code below but I am getting the error "Required String parameter 'requestJson' is not present". I would appreciate some advice. String url = mediaOrchestrationHost + "/DataOrchestration/v1/" + orchestration + "/media/createMediaWithData"; String json = "{\"expiry\":{\"type\":\"SESSION\"},\"filename\":\"file.txt\"}"; Part[] parts = new Part[]{new StringPart("requestJson", json), new FilePart("file.txt", new ByteArrayPartSource("file.txt", text.getBytes()))}; PostMethod method = new PostMethod(url); MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, method.getParams()); method.setRequestEntity(reqEntity); InfraHttpClient infraHttpClient = InfraHttpClientFactory.getHttpClient(); InfraMultipartPostMethod infraMultipartPostMethod = new InfraMultipartPostMethod(method, _ServiceName); infraMultipartPostMethod.setMessageBody(json); infraMultipartPostMethod.setSuppressSecurityHeaders(false); infraMultipartPostMethod.setSuppressTrmrHeaders(false); infraMultipartPostMethod.setSuppressRoutingCookies(false); for (String key : requestHeaders.keySet()) { infraMultipartPostMethod.getRequestHeaders().put(key, requestHeaders.get(key)); } infraHttpClient.executeMethod(infraMultipartPostMethod); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( infraMultipartPostMethod.getResponseStream()));

Answers

  • It appears that the problem is that Data Orchestration uses the old infrahttpclient with does not support multipartPost and is currently being upgraded to support httpclient4 which will support it.