从docusign sdk,我试图获取信封,但得到“原因:提供的URL无法解析为资源。” 404错误

问题描述 投票:0回答:1

我正在尝试从SDK创建信封,但收到这样的错误

原因:提供的URL无法解析为资源。HTTP响应标头:HTTPHeaderDict({'Cache-Control':'no-cache','X-DocuSign-TraceToken':'22dad523-9f77-4b83-9481-1e376faf60d8','Date':'Thu,05 Dec 2019 13 :02:26 GMT','Content-Length':'0'})]

def worker(args):
    """
    1. Create the envelope request object
    2. Send the envelope
    """
    envelope_args = args["envelope_args"]
    #print(args)
    #print("envelope arrrgggsss")
    #print(envelope_args)
    # 1. Create the envelope request object
    envelope_definition = make_envelope(envelope_args)
    #print(envelope_definition)
    # 2. call Envelopes::create API method
    # Exceptions will be caught by the calling function
    api_client = ApiClient()
    api_client.host = args["base_path"]
    print(api_client.host)
    api_client.set_default_header("Authorization", "token" + args["ds_access_token"])

    envelopes_api = EnvelopesApi(api_client)

    results = envelopes_api.create_envelope(args['account_id'], envelope_definition=envelope_definition)
    #print(results)
    envelope_id = results.envelope_id
    app.logger.info(f"Envelope was created. EnvelopeId {envelope_id}")

    return {"envelope_id": envelope_id}

在我尝试从以下代码获取令牌之前

def oauth2_token_request(root_url, username, password,
                             integrator_key):
        url = root_url + '/oauth2/token'
        data = {
            'grant_type': 'password',
            'client_id': integrator_key,
            'username': username,
            'password': password,
            'scope': 'api',
        }
        headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        response = requests.post(url, headers=headers, data=data)
        print(response)
        if response.status_code != 200:
            raise exceptions.DocuSignOAuth2Exception(response.json())

        return response.json()['access_token']

def oauth2_token_revoke(root_url, token):
        url = root_url + '/oauth2/revoke'
        data = {
            'token': token,
        }
        headers = {
            'Accept': 'application/json',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        response = requests.post(url, headers=headers, data=data)
        return response

        # if response.status_code != 200:
        #     raise exceptions.DocuSignOAuth2Exception(response.json())
python-3.x sdk docusignapi
1个回答
0
投票

似乎您将错误的API终结点设置为

/restapi/v2.1/accounts/9286679/restapi/v2.1/accounts/9286679/envelopes

而正确的URI是

/restapi/v2.1/accounts/9286679/envelopes

检查您的“ base_path”值。

© www.soinside.com 2019 - 2024. All rights reserved.