soapUI How to Post JSON to a REST Service

Automation Testing Published on:

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. So as requested here is a quick example on how POST JSON to a REST service using soapUI.

Setup – CouchDB

To make this example as easy as possible, without having to setup 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:

  2. Click on Download and choose the version you want to us
  3. Once it's installed, enter in a browser. This should bring up your local CouchDB Futton web site.
  4. Next, click on the Create Database and name it “soapUI”
  5. Navigate back to 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:

  1. Create a new project in soapUI. Enter Project Name: JSON. Click OK

  2. Right Click on the JSON project we just created and select New REST Service
  3. In the New REST Service screen enter:

    Service Name: JSON

    Service Endpoint:

    Check ‘Opens dialog to create a REST Resource'

  4. In the New REST Resource enter:

    Resource Name: soapui

    Resource Pat/Endpoint: soapui

    Click OK

  5. In the New REST Method screen enter:

    Method Name: PostJSONName

    HTTP Method: POST

    Click OK

  6. This is where most people get confused. Notice under the Request 1's Media Type how there is not an option for JSON

Not worries—all you need to do is type application/json into the Media Type field

  1. In the text area under the Media Type enter your json that you want to post. Let's keep it simple and create a JSON value that contains one name/value pair string: {“name”:”JoeColantonio”}

  2. Submit the Request 1. Notice in the response how it returns the value ok and an id
  3. Go back to couchDB. The soapui db should now have a value of 1 and should contain the name you just submitted:

Rest Easy

That's it! You can now rest easy in the knowledge that you now know how to !