POST JSON to a REST service using soapUI
Since my previous post on How to Test a REST Web Service, I've received a few requests asking for an example using JSON. I originally wrote this in 2013 and wanted to see if it still worked. Here are the updated steps for how to post JSON to a REST service using soapUI for 2022 :)
So as requested here is a quick example of how POST JSON to a REST service using soapUI.
Setup – CouchDB
To make this example as easy as possible, without having to set up any sort of authentication, I've decided to 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 with soapUI and JSON.
To install couchDB go to:
- 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 website.
- Next, click on the Create Database and name it “soapui”
- Navigate back to http://127.0.0.1:5984/_utils/index.html. Notice that soapui shows 0 docs.
How to use soapUI to send JSON to a REST API
Here are the steps to follow to get started using the free version of soapUI with REST testing:
- Create a new empty project in soapUI. Enter Project Name: JSON. Click OK
- Right Click on the JSON project we just created and select New REST Service from URI
- In the New REST Service screen enter:
- Method: Post
- Resource : soapui
7. Submit the Request 1. Notice in the response how it returns the value ok and an id
8. Go back to couchDB. The soapui db should now have a value of 1 and should contain the name you just submitted:
That's it! You can now rest easy in the knowledge that you now know how to !