как загрузить подписанный документ из docusign, используя envelopeid -java - PullRequest
0 голосов
/ 12 июня 2019

Я хочу загрузить подписанный документ из docusign. Я создал для этого новый конверт. Это правильный способ загрузки документа? Я также пытался использовать существующий конверт, который используется для подписания документа. envelopeid, я получаю исключение аутентификации.

 *JSONObject json=null;
            String accessToken = null;
            try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
                List<NameValuePair> form = new ArrayList<>();
                form.add(new BasicNameValuePair("scope", "api"));
                form.add(new BasicNameValuePair("username", docUsername));
                form.add(new BasicNameValuePair("password", docPassword));
                form.add(new BasicNameValuePair("grant_type", docGranttype));
                form.add(new BasicNameValuePair("client_id", docClientId));
                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(form, Consts.UTF_8);
                HttpPost httpPost = new HttpPost(docTokenurl);
                httpPost.setEntity(entity);
                System.out.println("Executing request " + httpPost.getRequestLine());
                // Create a custom response handler
                ResponseHandler<String> responseHandler = response -> {
                    int status = response.getStatusLine().getStatusCode();
                    if (status >= 200 && status < 300) {
                        HttpEntity responseEntity = response.getEntity();
                        return responseEntity != null ? EntityUtils.toString(responseEntity) : null;
                    } else {
                        throw new ClientProtocolException("Unexpected response status: " + status);
                    }
                };
                String responseBody = httpclient.execute(httpPost, responseHandler);
                System.out.println("----------------------------------------");
                System.out.println(responseBody);
                json = new JSONObject(responseBody);
                accessToken = json.getString("access_token");


            String accountId = docAccountId;
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();

            ApiClient apiClient = new ApiClient(docBasePath);
            apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results = envelopesApi.createEnvelope(accountId, envelopeDefinition);
            String envelopeId = results.getEnvelopeId();

            EnvelopeDocumentsResult docsList = envelopesApi.listDocuments(docAccountId, envelopeId);
            for( EnvelopeDocument doc: docsList.getEnvelopeDocuments() ) {

                Files.write(
                        new File(doc.getName()).toPath(),envelopesApi.getDocument(docAccountId, envelopeId, doc.getDocumentId())
                        );
            }*

1 Ответ

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

Если вы хотите загрузить подписанные документы из существующего конверта, используйте идентификатор существующего конверта. Смотрите документы для EnvelopeDocuments :: get

См. Примеры кода, начинающиеся с eg-03, на github.com/docusign

.

См. Примеры рабочих процессов 6 и 7.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...