Setting Up HTTPie for Akamai

by Javier Garza
2646

If you’re a Web Developer or DevOps, you probably have to deal with several API systems daily. HTTPie allows you to easily explore APIs before you decide if it’s worth to spend the effort to code a client using one of the programming languages like Python, Ruby, Go, etc.

This blog is going to explain a few tips you can use to improve the experience of using HTTPie with Akamai systems.

Get Started with HTTPie and Akamai

First, if you’re not already using HTTPie with Akamai, see this excellent post for instructions: Exploring Akamai OPEN APIs from the command line using HTTPie and jq.

Once you’re up and running, open the HTTPie configuration file located at ~/.httpie/config.json (or %APPDATA%\httpie\config.json on Windows).

NOTE: The config directory location can be changed by setting the HTTPIE_CONFIG_DIR environment variable. To view the exact location run http –debug.

Edit the Configuration File

To make HTTPie work better with Akamai systems, edit the file to match the following:

The lines in bold text are the default options you can configure. Here’s what they do:

--auth-type=edgegrid
If you installed the httpie-edgegrid package using “git clone https://github.com/akamai-open/httpie-edgegrid.git”, you can put the parameter on the config file to have it indicated by default so instead of calls like:

you can run:
--timeout=300
By default HTTPie’s timeout is 30 seconds. Unfortunately some API calls may take over 30s, so it is always good to have a higher timeout.
--session-read-only","~/.httpie-custom-headers.json"
Allows adding the infamous Akamai debug headers to each HTTPie outgoing request. See Using Akamai Pragma headers to investigate or troubleshoot Akamai content delivery for more information about using the Pragma headers.

The file ~/.httpie-custom-headers.json will contain the following:

-adefault:
Tells HTTPie to use the default session when no session is present.

Categories: Technology

Suggested Article

LEAVE A REPLY