Aan de slagGa gratis aan de slag

Using request and response headers

Headers contain additional information about your API calls, including the desired or used response format. Using accept and content-type headers, client and server can negotiate what response format to use.

In this exercise, you'll use headers to inspect response formats after making a request and make a new request specifying the desired format via the accept header.

The requests package has been imported for your convenience.

Deze oefening maakt deel uit van de cursus

Introduction to APIs in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

response = requests.get('http://localhost:3000/lyrics')

# Print the response content-type header
print(response.____)
Code bewerken en uitvoeren