You need to simulate a file upload, which requires a particular content type header, body parameters, etc. Something like this should do the trick.
You need to simulate a file upload, which requires a particular content type header, body parameters, etc. Something like this should do the trick: // Fill out the "form"... MultiValueMap parameters = new LinkedMultiValueMap(); parameters. Add("file", new FileSystemResource("file. Jpg")); // load file into parameter parameters.
Add("blah", blah); // some other form field // Set the headers... HttpHeaders headers = new HttpHeaders(); headers. Set("Content-Type", "multipart/form-data"); // we are sending a form headers. Set("Accept", "text/plain"); // looks like you want a string back // Fire!
String result = restTemplate. Exchange( "http://localhost:8080/sendScreeenAsPostCard", HttpMethod. POST, new HttpEntity(parameters, headers), String.
Class ).getBody().
Ok, I think I might be making some progress thanks to you. I am getting a 404 error which I think could be related to my post method's signature? – Bill Lee Aug 9 at 23:25 It looks like you are using Spring MVC with annotations, so I expect your sendScreenAsPostcard method should have something like @RequestMapping(method=POST, value="/sendScreeenAsPostCard") on it.
Then depending on web. Xml, container behavior, etc. There might be something before your endpoint (ex. Tomcat by default wants the WAR name right after the host/port).
Also there are 3 e's in your method - 404 due to typo? Lastly, when Spring loads and things are configured correctly, you should see it log all the endpoints it thinks it is exposing so you can verify. – SingleShot Aug 9 at 23:43 Allthree of your points have been EXTRAORDINARILY helpful.
Now I am getting a 406 error. My spelling was wrong and I have changed my parameters in my call so much thinking that was the problem. Here is the signature.
I was getting a 406 Error and the current error I am receiving is 500. @RequestMapping(value = "/sendScreenAsPostcard", method = { RequestMethod. POST }) – Bill Lee Aug 10 at 0:20 I get it to work if I have the method only use sendScreenAsPostcard(HttpServletRequest request) but unable to get values.
– Bill Lee Aug 10 at 0:40 I looked at my own file upload that uses @RequestParams - each of my parameters names the parameter from the HTTP form, for example: @RequestParam("file") MultipartFile file, @RequestParam("userId") String userId (note the HTTP names in quotes). Perhaps try that. – SingleShot Aug 10 at 15:26.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.