简体   繁体   中英

Docusign Ruby API - receiving 302 when try to do something

I am getting 302 when I try to do something with docusign-ruby-client.

envelope_args = {
  signer_email: 'email@email.com',
  signer_name: 'Name',
  cc_email: 'another@email.com',
  cc_name: 'Another name',
  template_id: 'template-id'
}

args = {
  client_id: 'my-client-id',
  impersonated_user_guid: 'my-impersonated-user-guid',
  base_path: 'account-d.docusign.com',
  envelope_args: envelope_args
}

envelope_args = args[:envelope_args]
configuration = DocuSign_eSign::Configuration.new
configuration.host = args[:base_path]

path = File.join(File.dirname(File.absolute_path(__FILE__)), 'private-key.txt')
private_key = File.read(path)

api_client = DocuSign_eSign::ApiClient.new configuration
api_client.set_oauth_base_path(args[:base_path])

token = api_client.request_jwt_user_token(args[:client_id], args[:impersonated_user_guid], private_key, 3600)

user_info = api_client.get_user_info(token.access_token)
template_api = DocuSign_eSign::TemplatesApi.new(api_client)
template_api.list_templates(user_info.accounts.first.account_id)

I created an JWT integration key, also authorized my user/ app and I see that I have an user_info.accounts.first.account_id when I execute user_info = api_client.get_user_info(token.access_token) .

When I try to execute any api.list_something I receive:

302
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://account-d.docusign.com/">here</a>.</h2>
</body></html>



I agree with @anothermh. Try setting your api_client's base path:

    api_client.config.host = 'https://demo.docusign.net/restapi'

The above base path is for demo (the developer sandbox).

For production, you need to pull the base path out of the get_user_info response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM