Command-line favorites: CURL
Curl is a powerful file transfer tool that supports a variety of protocols, and it's a piece of cake to test restful Web services. This tool is basically a UNIX-like operating system (a variety of Linux, Mac OS X) comes with it, and Windows users have to go for additional downloads.
Curl has a number of command parameters that are typically used for restful WEB services tests using the following four parameters:
- -d/–data <data>:post Data Content
- -x/–request <command>: Specifies the requested method (automatically set to post when using-D)
- -h/–header <line>: Set Header information
- -i/–head: Displays only the HTTP header information returned
One of the simplest examples of resource acquisition is that you do not need to forcibly specify the Get method, just follow the URL directly behind Curl:
[Code light= "true"]
[Email protected] ~
$ Curl HTTP://DAYANJIA.COM/API/USER/101250001/
{"id": "student1", "name": "\u5b66\u751f\u4e00", "num": "101250001",
"Grade": "20101", "courses": [{"id": 1, "name": "\u8bfe\u7a0b\u4e00",
"Active": false, "identity": 0, "instructors": [{"id": "teacher1", "NA
Me ":" \u8001\u5e08\u4e00 "}]},{" id ": 2," name ":" \u8bfe\u7a0b\u4e8c "
, "active": True, "identity": 0, "instructors": [{"id": "teacher2", "NA
Me ":" \u8001\u5e08\u4e8c "}]},{" id ": 3," name ":" \u8bfe\u7a0b\u4e09 "
, "active": True, "identity": 0, "instructors": [{"id": "Teacher3", "NA
Me ":" \u8001\u5e08\u4e09 "}]}]}
[/code]
Then look at deleting a remote record and returning the HTTP header check whether the operation was successful:
[Code light= "true"]
[Email protected] ~
$ curl-i-X DELETE http://dayanjia.com/api/course/1/
http/1.1 OK
Date:thu, 16:50:46 GMT
Server:litespeed
Connection:close
x-powered-by:php/5.2.14
Content-type:text/html
content-length:0
[/code]
It should be noted that if you use-D or some other parameter you cannot directly see the HTTP headers that are returned, you cannot use-D and-I simultaneously. The solution is to take the -D/--dump-header
parameter and specify a file name to save the header data for viewing.
Browser-controlled favorites: a variety of plugins
Since ordinary browsers do not support operations other than get and post, it is difficult to view and send HTTP headers, so let the plugin extend its functionality! It is also a very convenient choice to allow people to perform various tests without leaving the browser. If you like the plugins described below, you might want to give them a rating on the appropriate page to support the author's work.
There is a simple REST client plugin under Chrome that provides a single form for various HTTP operations and can see the returned information.
Chrome plug-ins appear to be a bit shabby, then also popular developers love Firefox has a plug-in called Restclient, the plug-in developed by the Chinese, functionally support basic and OAuth login header sent, And it can be highlighted for the returned XML data.
Coffee control's favorite: Restclient
Here's what the coffee is, you know. The name is also very simple, this is a Java-written test gadget, the project home page mentions that it has command line and GUI two versions. For the convenience of operation we chose GUI version to look at. Since it's a piece of software, it's obviously more powerful than the browser plugin you just introduced. It supports the JSON and XML indentation and highlighting of the reply body, as well as the ability to set up a restful server with one click, plus the functionality of unit testing. Of the three tools introduced, my favorite is this one, especially its indentation highlighting function is very useful, convenient to view.
In fact, in addition to the following commonly used plug-ins or tools, their own python and other scripts to implement HTTP is also a good choice
API test:
Chrome Postman
Chrome:simple Rest Client Advanced Rest clientfirefox:rest client Script:py Thon Script
Recommended for RESTful WEB Services testing Tools