Unirest is not compatible with python3 and that's the library that mashape APIs' use on python projects.
I've decided to use python request library to make a POST request, but I'm getting a 400 HTTP error. Everything looks good to me, but I can't figure out what I'm doing wrong.
url = "https://japerk-text-processing.p.mashape.com/sentiment/"
myHeaders={
"X-Mashape-Key": mashape_key,
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}
myParams={
"language": "english",
"text": tweet_text
}
r = requests.post(url, headers=myHeaders, params=myParams)
print(r)
According to the docs, UNIREST takes the argument:
params
- Request Body as an associative array or object
However, requests, per its own documentation, uses params
to supply URL query parameters, not the request body.
Try using the data
parameter to pass an actual request body instead; see the docs again. You will probably have to keep double-checking parameter names in the two sets of documentation to ensure you're passing the right thing.