Specifying content type, Logout request headers, Sample logout request (python) – Brocade Network Advisor REST API Guide (Supporting Network Advisor 12.3.0) User Manual
Page 39: Sample logout request (java)

Brocade Network Advisor REST API Guide
25
53-1003160-01
Specifying content type
3
Logout request headers
A valid token is required for logout and this is sent through the HTTP request header. You must add
the header while forming the HTTP POST request.
Sample logout request (Python)
The following is an example of an HTTP POST request for logout sent using Python.
HttpClient hc = new HttpClient();
method = new PostMethod("http://10.24.48.103/rest/logout");
method.addRequestHeader("WStoken", token);
Sample logout request (Java)
The following is sample Java code for terminating a REST API session with Network Advisor.
HttpURLConnection con = null;
try {
/**
* Create the HTTP connection object with the URI, method and headers
*/
URL obj = new URL("http://10.24.48.103/rest/logout");
con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.addRequestProperty("WStoken", "wppCy/NGdC4o5gGFJjXRMv7blhc=");
System.out.println("CALLING POST http://10.24.48.103/rest/logout");
/**
* Make the HTTP call
*/
int responseCode = con.getResponseCode();
System.out.println("Response code is " + responseCode);
if (HttpURLConnection.HTTP_NO_CONTENT != responseCode) {
PRINT_ERROR(con);
assert false : "REST FAILED for logout, responseCode = " + responseCode;
}
} catch (IOException ie) {
System.out.println(ie.toString());
} finally {
if (null != con) {
con.disconnect();
}
}
Specifying content type
All Brocade Network Advisor REST API requests that return data support both XML and JSON
formats. Depending on the content type you request, the proper data format is returned.
TABLE 7
Logout request headers
Request header name
Request header value
WStoken
The token obtained from login