首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Python服务器调用Personality Insights API

从Python服务器调用Personality Insights API
EN

Stack Overflow用户
提问于 2016-07-11 21:08:26
回答 0查看 429关注 0票数 0

我试图从我的Python web应用程序调用Personality Insights API,但它总是返回禁止错误403,但是当我从Postman Chrome扩展调用它时,它成功地工作了。

这是我的python代码:

代码语言:javascript
复制
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不允许接受来自服务器端应用程序的请求?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38307811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档