API testing Lesson 3

The third lesson - again we will do a PUT, but now not an empty one, but pass a value in it.

Suppose that we received an email from the client saying that our API got an additional endpoint /api/order/ and a new version of the documentation.

Base URL: 'http://www.answerit.ru' 1. Resource: /api/testing/get Method: GET Response: 200 OK 2. Resource: /api/put Method: PUT Response: 200 OK 3. Resource: /api/order/<int:put_id> Method: PUT Response: 200 OK Order with id <put_id> was added to the system. Thank you!

Immediately note that after /api/order/ some strange construction appears.

The thing is that this is how a variable value of integer type was denoted in the documentation.

You can come across different styles of denoting variables in API documentation

For example: /api/order/%put_id

Or /api/order/#put_id#

I suspect it depends on which language programming the developer who made the API documentation is used to writing in

Now you need to check whether a PUT request returns a 200 response and the message

Order with id <put_id> was added to the system. Thank you!

Where put_id is an integer that we will pass in the URL. But one thing at a time.

We continue working with SOAP UI and will update the project from the second lesson

I remind you of my advice from the previous lesson - change the name Method 1 in the previous request to something new, for example Method01

Right-click on answerit.ru and choose New Resource

Example of API testing, image from website www.aredel.com

Enter the new Resource Path that we learned from the API documentation, reread the documentation

Example of API testing, image from website www.aredel.com

Change the HTTP Method from GET to PUT.

While at it, I recommend renaming Method 1 to Method02

Example of API testing, image from website www.aredel.com

Add some integer after /order/; I am adding 2020

Since we added 2020, as the response we expect

Order with id 2020 was added to the system. Thank you!

Example of API testing, image from website www.aredel.com

Run the request (click the green triangle)

And study the response

Example of API testing, image from website www.aredel.com

We got the response:

Order with id 2020 was added to the system. Thank you!

As expected. Status 200 OK is there as well.

Why I ask you to change the names Method 1. In some versions of SOAP UI, if you create several identical HTTP requests to one base URL in one project, SOAP UI does not distinguish them and all the specified paths become equal to the last one.

We created two PUT requests, so the new PUT could spoil the old one by overwriting /api/put and writing /api/order/2020, that is, instead of two different requests we would have two identical ones.

Example of API testing, image from website www.aredel.com

If 200 did not come it means my site is down. Write in the comments whether it worked or not.

As an exercise try sending a request with a different number, send a request where instead of a number there are some other characters.

I hope you did not skip it and saw that if you pass not a number but, for example, the string ABC - a 404 error comes back.

Example of API testing, image from website www.aredel.com

A big request - do not send too many requests. I am not sure what load the site on my plan can withstand.

Article author: Andrei Olegovich

Banner image