IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to APIs in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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

# Print the response content-type header
print(response.____)
Modifica ed esegui il codice