MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Introduction to APIs in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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

# Print the response content-type header
print(response.____)
Edit dan Jalankan Kode