作文检索接口参数错误求助
bensquall 发布于2021-03 浏览:4807 回复:3
0
收藏

一直返回100,可是文档里只写了两个参数access_token和query。

有大神可以帮忙看看哪里参数不对吗?

{"error_code":100,"error_msg":"Invalid parameter"}

URL = 'https://aip.baidubce.com/rpc/2.0/kg/v1/cognitive/composition'

    params = {
              'access_token': Access_Token,
              'query': '我长大了的记叙文'
              }
    post_data = json.dumps(params, sort_keys=False)
    # print post_data
    req = Request(ASR_URL, post_data.encode('utf-8'))
    req.add_header('Content-Type', 'application/json')
    try:
        begin = timer()
        proxyHandler = ProxyHandler(ssmeProxy)
        opener = build_opener(proxyHandler)
        f = opener.open(req)
        result_str = f.read()

收藏
点赞
0
个赞
共3条回复 最后由用户已被禁言回复于2022-03
#4bensquall回复于2021-03

找到原因的:是因为access_token是URL参数

0
#3bensquall回复于2021-03

文档里只写了两个参数access_token和query。这两个参数我都传了啊

0
#2用户已被禁言回复于2021-03

access_token是URL参数。

https://aip.baidubce.com/rpc/2.0/kg/v1/cognitive/composition?access_token=你获取到的值

 

接口文档 https://ai.baidu.com/ai-doc/KG/8kf27k4g4  也明确告知相关参数所在位置了呢。

 

http协议建议自己最好有一定的基础或了解

 

 

1
快速回复
TOP
切换版块