خرید بک لینک

Vote count: 0

I have a post method that should post something to an url in the format of: http://jasperserver.com?update=true. If I sent the request with something like postmen, the request works fine.

When I use the code below tough, it doesn't seem like the update parameter does anything. I thought that the {update} would be replaced by true from the vars map.

String url = "http://jasperserver.com/import?update={update}";

HttpHeaders headers = createHttpHeaders(MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON, jasperServerSetting);

MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("name", patch.issue);
map.add("filename", patch.issue);

ByteArrayResource contentAsResource = new ByteArrayResource(someFile);;
map.add("file",  contentAsResource);
map.add("update", true);

Map<String, Object> vars = new HashMap<String, Object>();
vars.put("update", true);       

HttpEntity<?> request = new HttpEntity<Object>(map, headers);

RestTemplate restTemplate = new RestTemplate();
ImportExportResponse response = restTemplate.postForObject(url, request, ImportExportResponse.class,vars);

PS: I also tried to just put the complete url string (e.g. http://jasperserver.com/import?update=true) in the restTemplate. But that also doesn't seem to work. I'm kinda stuck here.

asked 1 min ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: جمعه 14 اسفند 1394 ساعت: 20:42

صفحه بندی