Introduction ...
The first API to test is the "TestGet ". In this scenario, the request is sent with only the "firstName" input. The request does not contain the second mandatory input: "lastName". So we expect the response to return with an error.
Code Blocklanguage bash js title TestGet request: Missing Last Name
curl -X GET "http://127.0.0.1:4021/testGet?firstName=John"
...
In this scenario, the request is sent with all the required input. The response should be a a JSON object containing the searched for object.
Code Blocklanguage bash js title TestGet request: Success linenumbers true
curl -X GET "http://127.0.0.1:4021/testGet?firstName=John&lastName=Smith"
...
Code Blocklanguage js title TestGet Reponse: Success linenumbers true
{"result": true,"data": {"firstName": "John","lastName": "Smith"}}
"testPost" API: Success This API is exactly like testGet but uses the "post" method.
Code Blocklanguage bash js title TestPost request: Sucess linenumbers true
curl -X POST -H "Content-type:application/json" -H "Accept:application/json" "http://127.0.0.1:4010/testPost" -d '{"firstName":"John","lastName":"Smith","email":"john@smith.com"}'
...
This request fails because of the invalid firstName "johnx" (Instead of "john"). This restriction is specified in the service itself.
Code Blocklanguage bash js title TestPost request: Failure linenumbers true
curl -X POST -H "Content-type:application/json" -H "Accept:application/json" "http://127.0.0.1:4021/testPost" -d '{"firstName":"Johnx","lastName":"Smith"}'
...
SOAJS also provides supports the PUT method:
Code Blocklanguage bash js title TestPut request: Success linenumbers true
curl -X PUT -H "Content-type:application/json" -H "Accept:application/json" "http://127.0.0.1:4021/testPut" -d '{"firstName":"John","lastName":"Smith"}'
...
SOAJS also provides supports the DEL protocol:
Code Blocklanguage bash js title TestDel request: Success linenumbers true
curl -X DELETE "http://127.0.0.1:4021/testDel?firstName=John&lastName=Smith"
...
In this first request, both "firstName" and a "lastName" parameters are supplied.
Code Blocklanguage bash js title BuildName request: Success linenumbers true
curl -X GET "http://127.0.0.1:4021/buildName?firstName=James&lastName=Smith"
...
"buildName" API: Success (No FirstName Parameter)In this test, the "firstName" parameter is not supplied. However, since the API is configured to fallback to a default value, no error response is generated. Rather, a response containing the default "firstName", in addition to the "lastName" supplied by the request, was generated instead.
Code Blocklanguage bash js title BuildName request: Success linenumbers true
curl -X GET "http://127.0.0.1:4021/buildName?lastName=Smith"
Code Blocklanguage js title BuildName request: success linenumbers true
{"result": true,"data": {"fullName": "John Smith"}}