-
Notifications
You must be signed in to change notification settings - Fork 34
Description
while sending the request using resttemplate, I set the content type as multipart/form-data but it had not worked.
code :
MultiValueMap<String, Object> bodyMap = new LinkedMultiValueMap<>();
String token="01OZX5nhEuRR0aje3iG1wPs6PkpFdUTGPiastIoVzpLdoHdFNBDz-DWZkm9pdmqJq1XOQOziMeYYVFdfBGv43XgNzIGzA";
File file= new File("E:/mp3/AAJA MAHIYA.MP3");
bodyMap.add("media", file);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.setBearerAuth(token);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(bodyMap, headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity response = restTemplate.exchange("https://api.temi.com/v1/jobs",
HttpMethod.POST, requestEntity, String.class);
System.out.println("response status: " + response.getStatusCode());
System.out.println("response body: " + response.getBody());
But this code throws bad request 400.
but same thing i do with postman response code is 403 (account still not subscribed).
I need to send file object from body and then form data it can be possible by using resttemplate?
please refer the attachment.
