Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 10
Part no.9036931-00 Rev AA February 2021
Wen working with REST API, (and any API using HTTP), you will most likely need to manipulate the
headers using the content-type, accept, authorization and x-auth-token commands.
Note: The HTTP Archive site is an excellent resource for learning more about HTTP. This site
monitors the top 1.3M web sites and extracts the HTTP information for analyses. This
information, along with reports such as State of the Web , are accessible to the public.
2.2.4.1 Content-Type
The content-type indicates, as the name implies, what is the format of the data in the body. This is a
very important piece of knowledge, as you would not treat that data the same way if this is pure text
html, some binary form or some JSON data for an application.
In your context of a REST API, you’ll most likely use the “application/json” value for this parameter, as
long as you are, indeed, transmitting data in JSON format.
Content-Type: application/json
HTTPS://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
2.2.4.2 Accept
The client uses the Accept header to advertise which content types it can understand. The server
informs the client of the choice using the Content-Type header. In REST API, the accept header is often
set to “application/json”.
Accept: application/json
HTTPS://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
2.2.4.3 Authorization
The authorization request header contains the credentials required to authenticate a user agent (a
client) with a server. The authorization header value format is <type> <credential> with a space
between them.
The typical Basic authentication type concatenates the username and the password in a single string,
separated by a colon (:). This means that a username cannot also contain a colon. The result is encoded
in base64. This is not an encryption because it is reversible.
To access an online tool that can encode and decode in base64, visit: HTTPS://www.base64encode.org/
As an example, the string stef:extreme is encoded in base64 as c3RlZjpleHRyZW1l.
authorization: Basic c3RlZjpleHRyZW1l
HTTPS://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization