API Testing Lesson 6
Two Methods for One Endpoint
The very same Endpoint /api/multiply_two/ now also accepts a GET request, so the specification looks as follows:
Base URL: 'http://www.answerit.ru' … 5. Resource: /api/multiply_two/ Method: GET Response: 200 OK This endpoint allows to multiply numbers. Use POST method to send two numbers factor_1 and factor_2 of type int or float. format request body as JSON. Response will include info about their product. Method: POST Body: { "factor_1" : float, "factor_2" : float } Responses: 200 OK application/json {"Success":"Product of %factor_1% and %factor_2% is %product%"} where %product% = %factor_1% * %factor_2% …
What is new in the documentation:
/api/multiply_two/ has got a second method
In the previous lesson you could send only POST
with a body in JSON format.
In the current version you can send GET as well
To add a new method to an existing resource (Resource) you need to right-click the resource and choose New Method
GET is created by default, so all you need to do is change the method name from Method 1 to something else.
We send the request and, if everything went well, we get the reference information.
The developer attached a GET reference and
a POST multiplication to /api/multiply_two/.
We have just checked GET. We checked POST in the previous lesson, but
I recommend that you check the multiplication once more.
It often happens that, by adding new functionality, developers break the old one.
A big request - do not send too many requests. I am not sure what load the site can handle on my plan.
Article author: Andrei Olegovich