Hello Evan,
As referenced
here, the header must include the formatted to include a new key-value pairing (being x-api-key: '<API_KEY>')
With regards to the requests library, when inserting this code you see below, simply
calling the get() function and passing a url does NOT modify the header dictionary.
=================================ISSUE REPLICATION=================================
print(post.request.headers)
print("Status Code: " + str(post.status_code))
print(post.content)
REFER TO: PROBLEM.png Attachment
=================================SOLN=================================
When you pass in an authentication parameter, underneath the hood the requests library ingests this object and
uses whatever authentication data contained within the object's fields to build the properly formatted header.
For
example, some APIs require generic username and password fields which
can be passed to the header using HTTPBasicAuth() class.
The
extra hurdle here is that this MTA API requires a custom authentication
header entry (being 'x-api-key': 'API_KEY') which can be created
using TokenAuth() wrapper class as such:
print(post.request.headers)
print("Status Code: " + str(post.status_code))
print(post.content)
REFER TO: SOLN.png Attachment
As you can see, the status is a 200 == success.
for more details on how to setup the custom TokenAuth() class (or whatever name you want to call it).
It's pretty boilerplate so you should get it to work exactly without issue. Just alter 'X-TokenAuth' in the example to 'x-api-key' ... let me know if this helps.