Reputation: 702
I am trying to make a request following the IBM Tone Analyzer API instructions, and according to the docs this is what it'll look like.
curl -X POST -u "apikey:{apikey}" --header "Content-Type: application/json" --data-binary @tone.json "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2017-09-21"
I converted that to a python request()
and I have this:
response = requests.post(url=analyzer_url, header=header, data=data)
the problem is that I have no clue what -u "apikey:{apikey}"
's equivalent is on the request()
parameters.
Could anyone help me?
Upvotes: 0
Views: 882
Reputation: 702
Well I did look at this question but I don't think they talk about the -u "apikey:{apikey}"
which was the main source of my issue. (what I now know is Authentication).
I found my answer thanks to Bakuriu's reply (here) My final post
request looked like this:
res = requests.post(
url,
headers=headers,
data=json.dumps(my_json).encode('utf-8'),
auth=("apikey", API_KEY)
)
(I wish the folks in the comment section had taken the time to read the context of my question rather than looking for a duplicate. @ Bakuriu your response helped me the most, but you just didn't submit an actual answer, so I had to answer my own question.)
Upvotes: 2