Postman This tool allows you to easily test your Web API, that if you really can not use Postman, must be hand-written code, or if you have other needs Postman is not achieved, you have to write a special script or the App to test your interface, then this is not the time Postman no useful here?
I come to you share a little trick bar, tube does not count what you say.
Suppose I now want this to measure my interfaces:
We want to set up a user name and password:
We want to set the parameters and Header:
? If you had to write code to generate the HTTP Request is not feeling a bit of trouble if you are lazy, you open Postman, with good you want HTTP Request, and then click Generate Code image above it, in the pop-up window inside, you can see this Request correspondence written in various languages inside, such as the Java the OK HTTP:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://maps.googleapis.com/maps/api/geocode/json?Address=%E4%B8%AD%E5%9B%BD%E5%9B%9B%E5%B7%9D%E6%88%90%E9%83%BD%E5%B8%82%E5%A4%A9%E5%8D%8E%E4%B8%80%E8%B7%AF&sensor=true")
.get()
.addHeader("accept", "application/xml")
.addHeader("cache-control", "no-cache")
.addHeader("pragma", "text/cmd")
.addHeader("postman-token", "6f00b02c-419f-9b98-f2d3-942ddd1ba081")
.build();
Response response = client.newCall(request).execute();
Such as JavaScript AJAX:
var settings = {
"async": true,
"crossDomain": true,
"url": "http://maps.googleapis.com/maps/api/geocode/json?Address=%E4%B8%AD%E5%9B%BD%E5%9B%9B%E5%B7%9D%E6%88%90%E9%83%BD%E5%B8%82%E5%A4%A9%E5%8D%8E%E4%B8%80%E8%B7%AF&sensor=true",
"method": "GET",
"headers": {
"accept": "application/xml",
"cache-control": "no-cache",
"pragma": "text/cmd",
"postman-token": "c7d566f4-0e21-9680-e47f-667b3e65280d"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});