BulkEnvelopesApi Docusign формат данных запроса - PullRequest
0 голосов
/ 13 июня 2018

Я застрял при использовании BulkEnvelopesApi от Docusign API для Ruby.Он продолжает возвращать мне эту ошибку:

DocuSign_eSign :: ApiError (неверный запрос):

Редактировать: после предложения @kiddorails включить debug = True, сообщение об ошибкеis:

{"errorCode": "UNSPECIFIED_ERROR", "message": "Значение не может быть нулевым. \ r \ nПараметр параметра: поток"}

Яиспользуя этот драгоценный камень: https://github.com/docusign/docusign-ruby-client

Что-то не так с форматом ввода данных?

Вот мой код для справки.

  def self.send_env()
    self.auth # To initialize the @api_client

    t1 = DocuSign_eSign::TemplatesApi.new(@api_client)
    signer_placeholder ={"signers":[{"email":"bulk@recipient.com","name":"Bulk Recipient",
                                     "routingOrder":1,"recipientId":"1","roleName":"Fruit",
                                     "isBulkRecipient":"True"}]}
    t1.update_recipients(account_id=ENV["ACCOUNT_ID_LIVE"], template_id=ENV["TEMPLATE_ID_LIVE"], template_recipients=signer_placeholder)
    br = DocuSign_eSign::BulkRecipient.new(
        {
            "accessCode": '112233',
            "email": 'berry@gmail.com',
            "name": 'Berry',
            "rowNumber":1
        }
    )

    brr = DocuSign_eSign::BulkRecipientsRequest.new({"bulkRecipients": Array(br)})
    bea = DocuSign_eSign::BulkEnvelopesApi.new(@api_client)
    bea.update_recipients(account_id=ENV["ACCOUNT_ID_LIVE"], envelope_id=ENV["TEMPLATE_ID_LIVE"],
                      recipient_id="1",bulk_recipients_request=brr)

Явозможность вызывать другие API Docusign, используя этот аналогичный формат данных.Невозможно работать только с BulkEnvelopesAPI.

Я думаю, есть ли что-то не так с исходным кодом для этой функции BulkEnvelopesAPI.

Спасибо за чтение!

1 Ответ

0 голосов
/ 13 июня 2018

С помощью @kiddorails мне удалось ее решить.

Вот решение:

Сначала отредактируйте исходный код в этом формате.Основная идея состоит в том, чтобы изменить Content-Type на 'text / csv' и ввести строку в тело.

def update_recipients_with_http_info(account_id, envelope_id, recipient_id, bulk_recipients_request)
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: BulkEnvelopesApi.update_recipients ..."
      end
      # verify the required parameter 'account_id' is set
      fail ArgumentError, "Missing the required parameter 'account_id' when calling BulkEnvelopesApi.update_recipients" if account_id.nil?
      # verify the required parameter 'envelope_id' is set
      fail ArgumentError, "Missing the required parameter 'envelope_id' when calling BulkEnvelopesApi.update_recipients" if envelope_id.nil?
      # verify the required parameter 'recipient_id' is set
      fail ArgumentError, "Missing the required parameter 'recipient_id' when calling BulkEnvelopesApi.update_recipients" if recipient_id.nil?
      # resource path
      local_var_path = "/v2/accounts/{accountId}/envelopes/{envelopeId}/recipients/{recipientId}/bulk_recipients".sub('{format}','json').sub('{' + 'accountId' + '}', account_id.to_s).sub('{' + 'envelopeId' + '}', envelope_id.to_s).sub('{' + 'recipientId' + '}', recipient_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params['Content-Type'] = 'text/csv'
      # form parameters
      form_params = {}

      # http body (model)
      # post_body = @api_client.object_to_http_body(bulk_recipients_request)
      # puts bulk_recipients_request
      # post_body = body_params
      auth_names = []
      data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => bulk_recipients_request,
        :auth_names => auth_names,
        :return_type => 'BulkRecipientsSummaryResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: BulkEnvelopesApi#update_recipients\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end

Во-вторых, установите bulk_recipients_request как строку (с символами новой строки для каждой строки данных)

"rowNumber,email,name,Accesscode\n"+"1,berry@gmail.com,Berry,11223\n"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...