List of usage examples for org.springframework.http HttpEntity HttpEntity
public HttpEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers)
From source file:br.edu.unifesspa.lcc.indexer.teste.java
public static void main(String[] args) { int assunto = 215; RestTemplate rt = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer d724997c-ba1d-42aa-8ed3-40a8a590558e"); HttpEntity<String> entity = new HttpEntity<>("parameters", headers); try {/*from w w w . jav a2 s . c o m*/ System.out.println("Comeando a inserir os Inputs do assunto: " + assunto); ResponseEntity<domain.Input_presenteDTO[]> input = rt.exchange( "http://xingu.lcc.unifesspa.edu.br:8080/api/input_presentes/getInputPresenteByAssantoId/" + assunto, HttpMethod.GET, entity, Input_presenteDTO[].class); System.out.println("Fez o download do assunto: " + assunto); System.out.println("Tamano input: " + input.getBody().length + " Assunto: " + assunto); } catch (Exception e) { } }
From source file:com.apress.prospringintegration.web.MultipartHttpClient.java
public static void main(String[] args) { RestTemplate template = new RestTemplate(); String uri = "http://localhost:8080/http-adapter-1.0.0/inboundMultipartAdapter.html"; Resource picture = new ClassPathResource("com/apress/prospringintegration/web/test.png"); MultiValueMap map = new LinkedMultiValueMap(); map.add("name", "John Smith"); map.add("picture", picture); HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("multipart", "form-data")); HttpEntity request = new HttpEntity(map, headers); ResponseEntity<?> httpResponse = template.exchange(uri, HttpMethod.POST, request, null); System.out.println("Status: " + httpResponse.getStatusCode().name()); }
From source file:cz.muni.fi.pa165.rentalofconstructionmachinery.restclient.MachineRestController.java
public static void newMachine(String licensePlate, String type) { MachineDTO machine = new MachineDTO(null, licensePlate, type); rt.postForLocation(MACHINE_URL, new HttpEntity<>(machine, httpHeaders)); }
From source file:org.trustedanalytics.h2oscoringengine.publisher.http.HttpCommunication.java
public static HttpEntity<String> postRequest(String body) { HttpHeaders headers = new HttpHeaders(); headers.add("Accept", JSON_ACCEPT_HEADER_VALUE); headers.add(CONTENT_TYPE_HEADER_NAME, "application/x-www-form-urlencoded"); return new HttpEntity<>(body, headers); }
From source file:edu.infsci2560.LoginHelper.java
public static ResponseEntity<String> login(TestRestTemplate template, String route, String userName, String password) {//from w ww .ja v a2 s . c om HttpHeaders headers = getHeaders(template, route); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>(); form.set("username", userName); form.set("password", password); ResponseEntity<String> entity = template.exchange(route, HttpMethod.POST, new HttpEntity<MultiValueMap<String, String>>(form, headers), String.class); return entity; }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String publishOntology(String fileClassPath, String format, String dataset) { RestTemplate restTemplate = new RestTemplate(); LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); final String uri = "http://localhost:8090/api/v1/ontology/publish"; //final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/publish"; map.add("file", new ClassPathResource(fileClassPath)); map.add("format", format); map.add("dataset", dataset); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<LinkedMultiValueMap<String, Object>> entity = new HttpEntity<LinkedMultiValueMap<String, Object>>( map, headers);/*from w w w . j a v a 2 s. c o m*/ String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:cz.muni.fi.pa165.rentalofconstructionmachinery.restclient.MachineRestController.java
public static void editMachine(Long id, String licensePlate, String type) { String url = MACHINE_URL + id; MachineDTO machine = new MachineDTO(id, licensePlate, type); rt.put(url, new HttpEntity<>(machine, httpHeaders)); }
From source file:com.joseph.california.test.restapi.PersonRestControllerTest.java
@Test public void tesCreate() { Person p = null;// ww w. j a v a 2 s . c o m HttpEntity<Person> requestEntity = new HttpEntity<>(p, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/person/create", HttpMethod.POST, requestEntity, String.class); }
From source file:com.nobu.dvdrentalweb.test.restapi.PersonRestControllerTest.java
@Test public void tesCreate() { Person p = new Person.Builder().firstname("nobu").age(5).build(); HttpEntity<Person> requestEntity = new HttpEntity<>(p, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/person/create", HttpMethod.POST, requestEntity, String.class); }
From source file:com.joseph.california.test.restapi.ClubRestControllerTest.java
public void tesCreate() { Club club = new Club.Builder("Hackers").build(); HttpEntity<Club> requestEntity = new HttpEntity<>(club, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/club/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); }