Skip to content

Instantly share code, notes, and snippets.

Last active September 23, 2022 14:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Service configuration
import com.fasterxml.jackson.databind.JsonNode;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
public class YourApiService {
private RequestSpecification spec;
protected void init() {
// On init you can set some global properties of RestAssured
spec = new RequestSpecBuilder().setBaseUri("").setBasePath("/api").build();
public Response postRequest(String endpoint, JsonNode requestBody) {
return RestAssured.given(spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment