Step 1 You need to get the Postman extension for the Google chrome browser.
Step 2 Search and add POSTMAN.
Step 3 Once installed, open it from the Apps link.
Step 4 Set the TEST URL, HTTP headers (especially the content type application/json, etc), and HTTP method (GET, POST, PUT, etc) and then click on send.
for the completeness, the REST service could have been implemented using Spring MVC, and the controller implementation looking like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import javax.ws.rs.core.MediaType; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import com.mgl.wrap.MyApp.enterprise.endpoint.controller.MyAppEnterpriseEndpointController; import com.mgl.wrap.MyApp.enterprise.schema.dto.OffLineElectionRequest; import com.mgl.wrap.MyApp.enterprise.schema.dto.OffLineElectionResponse; import com.mgl.wrap.MyApp.enterprise.schema.dto.PingResponse; /** * Spring MVC Controller for "MyApp Enterprise End Point". */ @Controller @RequestMapping(value = "/v1/app/enterprise", produces = { MediaType.APPLICATION_JSON }) public class MyAppEnterpriseEndpointControllerImpl implements MyAppEnterpriseEndpointController { private static final Logger LOG = LoggerFactory.getLogger(MyAppEnterpriseEndpointControllerImpl.class); @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/updateOfflineElection", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}, produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public OffLineElectionResponse updateOfflineElection( @RequestBody(required = true) final OffLineElectionRequest request) { OffLineElectionResponse response = new OffLineElectionResponse(); response.setMessage("Processed"); return response; } } |