Automation Testing

soapUI How to Post JSON to a REST Service

By Test Guild
  • Share:
Join the Guild for FREE
API Testing

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. 

In this post, I’ve shared:

  • how to setup Apache CouchDB – a kind of authentication
  • the updated steps for how to post JSON to a REST service using soapUI for 2022

INDEX
POST JSON to a REST service using soapUI
Setup – CouchDB
How to use soapUI to send JSON to a REST API|
Rest Easy

POST JSON to a REST service using soapUI

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:

    1. http://couchdb.apache.org/
    2. Click on Download and choose the version you want to us
    3. Once it's installed, enter http://127.0.0.1:5984/_utils/ in a browser. This should bring up your local CouchDB Futton website.
    4. Next, click on the Create Database and name it “soapUI.
    5. Navigate back to http://127.0.0.1:5984/_utils/index.html. Notice that soapUI shows 0 docs.

CouchDB soapUI database example

Automation Testing Training Courses

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 empty project in soapUI. Enter Project Name: JSON. Click OK
  2. Right Click on the JSON project we just created and select New REST Service from URI
  3. In the New REST Service screen enter:

URI: http://127.0.0.1:5984/

SoapUI REST URI

 

  1. In the Request 1 enter:
  • Method: Post
  • Resource: soapUI

SoapUI POST REST Settings

  1. This is where most people get confused – authentication. 

If you setup a username and password for your CouchDB install, click on the Request 1 Authentication tab. From the Authorization dropdown, select Basic. Enter your username and password as well as the Domain: http://127.0.0.1:5984/. Make sure to also click on the Authenticate pre-emptively radio button.

 

SoapUI REST Authentication

6. 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”}

JSON Key Values for SoapUI

7. Submit the Request 1. Notice in the response how it returns the value ok and an id

SoapUI REST Response

8. 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!

Work With Me

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

SafeTest: Next Generation Testing Framework from Netflix

Posted on 03/26/2024

When you think of Netflix the last thing you probably think about is ...

Top Free Automation Tools for Testing Desktop Applications (2024)

Posted on 03/24/2024

While many testers only focus on browser automation there is still a need ...

Bridging the Gap Between Manual and Automated Testing

Posted on 03/13/2024

There are some testers who say there’s no such thing as manual and ...