我试图从我的Python web应用程序调用Personality Insights API,但它总是返回禁止错误403,但是当我从Postman Chrome扩展调用它时,它成功地工作了。
这是我的python代码:
def generatePersonalDescription(request):
import requests
from requests.auth import HTTPBasicAuth
IBM_API_URL = "https://gateway.watsonplatform.net/personality-insights/api/v2/profile"
top_level_url = "https://gateway.watsonplatform.net/personality-insights/api"
username = "<user>"
password = "<password>"
JSON_OBJ = {'contentItems': [{'content' : 'strcontent' , 'contenttype': 'application/json','sourceid': 'blog123','language': 'en'}]}
json_data = json.dumps(JSON_OBJ)
resp = requests.get(IBM_API_URL, auth=(username, password))
return HttpResponse(resp)有没有可能因为python是一个服务器端,而API不允许接受来自服务器端应用程序的请求?
https://stackoverflow.com/questions/38307811
复制相似问题