0

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)
4

1 回答 1

0

根据文档,UNIREST 采用以下论点:

params- 请求正文作为关联数组或对象

但是,根据其自己的文档,请求params用于提供 URL 查询参数,而不是请求正文。

尝试使用data参数来传递实际的请求正文;再次查看文档。您可能必须反复检查两组文档中的参数名称,以确保您传递了正确的内容。

于 2017-01-28T23:20:17.497 回答