
In my last few posts we went over getting started with rest-assured and how to get request using the new given, when, then syntax — now that we have some get request method examples under our belt I wanted to take a look at a few examples of using Rest-Assured to test JSON REST services using the POST method.
Setup – CouchDB
To make this example as easy as possible and not have to setup any sort of authentication, I’ll use Apache couchDB. CouchDB is easy to install, stores data as JSON documents and has an easy-to-use API to interact with it. This makes it a great application to use to teach us more about REST testing rest-assured and JSON.
To install couchDB go to:
- http://couchdb.apache.org/
- Click on Download and choose the version you want to us
- Once it’s installed, enter http://127.0.0.1:5984/_utils/ in a browser. This should bring up your local CouchDB Futton web site.
- Next, click on the Create Database and name it “restassured”


- Navigate back to http://127.0.0.1:5984/_utils/index.html. Notice that restassured shows 0 docs.

You can also check out my SoapUI – How to Post Json to a Rest Service video for how to install couchDB.
Time to use Rest-Assured to Send a Post Request
For some reason, I had a hard time figuring out how to do this. Whatever the reason, I finally got it to work. Remember — I’m still learning this myself, and posting what I’m learning along the way. There may be better way of doing it, but for now I’m sharing what worked for me to hopefully help get you started if you’re also struggling to get the POST to work.
- In your IDE, create a new java class named CouchDB_REST
- Import the following:
import org.junit.Test; import org.junit.Before; import static com.jayway.restassured.RestAssured.expect; import static org.hamcrest.Matchers.equalTo;
- Create a public method named postExample
- Add the junit @Test annotation above it.
@Test
public void postExample()
{
String myJson = "{"name":"Jimi Hendrix"}";
RestAssured.baseURI = "http://127.0.0.1:5984/restassured";
Response r = given()
.contentType("application/json").
body("{"name":"Jimi Hendrix"}").
when().
post("");
String body = r.getBody().asString();
System.out.println(body);
}
- Right click on the CouchDB_REST.java and Run As>Junit Test
- Your test should pass

- Look for the id in the Console output:

- Go back to couchDB: http://127.0.0.1:5984/_utils/index.html
- Notice how your restassured now shows Number of Documents 1
- Click on the restassured db link and notice how the ID under the key column matches the id returned in the java console

More Rest-Assured Post
REST-ASSURED – HOW TO POST A JSON REQUEST
REST-assured How to Check Response Times
REST Testing with Java Part Two: Getting Started with Rest-Assured
Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.
Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.
With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.
He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.
Follow him on LinkedIn or check out more at TestGuild.com.
Related Posts
The 72.8% Paradox That Changes Everything After interviewing 50+ testing experts in 2025 and analyzing data from our 40,000+ member […]
Look, I’ve been doing this testing thing for over 25 years now. I first wrote about the AI “three waves” […]
What’s New in Low-Code/No-Code Testing for 2026 A lot had changed on the The low-code/no-code testing space and it has […]
I want to share an update on one of my favorite exploratory testing tools that just keeps getting better. I […]



