You've been asked to create a function in your program to upload a CSV extract of the daily data to ABQ's corporate web services, which uses an authenticated REST API. While urllib
is easy enough to use for simple one-off GET
and POST
requests, complex interactions involving authentication tokens, file uploads, or REST services can be frustrating and complicated using urllib
alone. To get this done, we'll turn to the requests
library.
Note
REST stands for REpresentational State Transfer, and is the name used for web services built around advanced HTTP semantics. In addition to GET
and POST
, REST APIs use additional HTTP methods like DELETE
, PUT
, and PATCH
, along with data formats like XML or JSON, to present an API with a complete range of interactions.
The third-party requests
library is highly recommended by the Python community for any serious work involving HTTP (even the urllib
documentation recommends it). As you'll see, requests
removes many of the rough edges and...