spring-projects / spring-projects/spring-integration-samples
rest-http POST method
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
i want to sent json by post method
after change integration configuration
and write test i send object but response is failed
<int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
supported-methods="POST"
request-payload-type="org.springframework.integration.samples.rest.domain.Employee"
request-channel="employeeSearchRequest"
reply-channel="employeeSearchResponse"
mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
path="/services/employee/{id}/search"
reply-timeout="50000"
>
@Test
public void testGetEmployeeAsJsonPOST() throws Exception {
Map<String, Object> employeeSearchMap = getEmployeeSearchMap("0");
final String fullUrl = "http://localhost:8080/rest-http/services/employee/{id}/search?format=json";
HttpHeaders headers = getHttpHeadersWithUserCredentials(new HttpHeaders());
headers.add("Accept", "application/json");
Employee em=new Employee(6, "ali akbar", "azizkhani");
HttpEntity<Employee> request = new HttpEntity<Employee>(em,headers);
ResponseEntity<?> httpResponse = restTemplate.exchange(fullUrl, HttpMethod.POST, request,EmployeeList.class, employeeSearchMap);
logger.info("Return Status :" + httpResponse.getHeaders().get("X-Return-Status"));
logger.info("Return Status Message :" + httpResponse.getHeaders().get("X-Return-Status-Msg"));
assertTrue(httpResponse.getStatusCode().equals(HttpStatus.OK));
ByteArrayOutputStream out = new ByteArrayOutputStream();
jaxbJacksonObjectMapper.writeValue(out, httpResponse.getBody());
logger.info(new String(out.toByteArray()));
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rest-http integration configuration and the testGetEmployeeAsJsonPOST test shown in the issue. Reproduce the JSON POST request and inspect the response and related comments to identify whether the failure is in request mapping, payload conversion, or the test setup. Done means the request succeeds with a documented regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100