In this short tutorial, I am going to share with you how to enable CrossOrigin in a RESTful Web Service API build with Spring Boot and Spring MVC. And to do that you need to simply annotate a method in your RestController class with @CrossOrigin annotation like in the example below. Enable CrossOrigin @CrossOrigin(origins = “http://localhost:8080”) @GetMapping(path =…

Read More CrossOrigin in RESTful Web Service

In this REST Assured tutorial, I am going to share with you how to evaluate the JSON content returned in the Response Body of HTTP Response. JSON Content Returned in Response Body Let’s say we have a RESTful Web Service endpoint that returns user details of the following structure: { “userId”: “Y3vWa8QwjK0DW6NmvB4HsXIV9gHg1q”, “firstName”: “Sergey”, “lastName”:…

Read More REST Assured Evaluate JSON Response Body

In this REST Assured tutorial, you will learn how to make HTTP Post request and validate the Response. To break it into more details you will learn: Make HTTP Post request with REST Assured, Create JSON Object using the com.google.gson library, Send JSON payload in the body of HTTP Post request, Validate the Response To be…

Read More REST Assured HTTP Post Request

In this REST Assured tutorial, you will learn how easy it is to test and validate RESTful APIs. REST Assured provides an excellent HTTP support, explicit verbs, and actions. We will use REST Assured in this tutorial, along with the Hamcrest library to perform assertions. REST Assured Maven Dependencies Before we start laying down examples for…

Read More REST Assured Tutorial

In this Spring MVC tutorial, you will learn how to make your RESTful Web Service endpoint respond back with either XML or JSON representation. To make your Web Service endpoint be able to respond with either XML or JSON representation include  MediaType.APPLICATION_JSON_VALUE  and MediaType.APPLICATION_XML_VALUE media types into the RequestMapping annotation of your resource method. For example: @GetMapping(path…

Read More Return XML or JSON in Spring MVC Web Service