Как решить «Ошибка при запросе сервера» при выполнении простого почтового запроса с использованием docusign - PullRequest
0 голосов
/ 28 июня 2018

получение ошибки Исключение: com.docusign.esign.client.ApiException: Ошибка при запросе сервера получил неуспешный код HTTP 401 с Тело ответа: '{"errorCode": "PARTNER_AUTHENTICATION_FAILED",
"message": "Указанный ключ интегратора не найден или отключен. Ключ интегратора не указан. "} '

при использовании следующего примера кода, понятия не имею, как решить эту проблему. Может ли кто-нибудь помочь мне решить эту ошибку

public class DocuSignExample {


    public static void main(String[] args) {
        byte[] fileBytes = null;

        String pathToDocument = "/TestFile.pdf";

        try
        {
            String currentDir = System.getProperty("user.dir");

            // read file from a local directory
            Path path = Paths.get(currentDir + pathToDocument);
            fileBytes = Files.readAllBytes(path);
        }
        catch (IOException ioExcp)
        {
            // TODO: handle error
            System.out.println("Exception: " + ioExcp);
            return;
        }

        // create an envelope that will store the document(s), field(s), and recipient(s)
        EnvelopeDefinition envDef = new EnvelopeDefinition();
        envDef.setEmailSubject("Please sign this document sent from Java SDK)");

        // add a document to the envelope
        Document doc = new Document();  
        String base64Doc = Base64.getEncoder().encodeToString(fileBytes);
        doc.setDocumentBase64(base64Doc);
        doc.setName("TestFile"); // can be different from actual file name
        doc.setFileExtension(".pdf"); // update if different extension!
        doc.setDocumentId("1");

        List<Document> docs = new ArrayList<Document>();
        docs.add(doc);
        envDef.setDocuments(docs);

        // add a recipient to sign the document, identified by name and email we used above
        Signer signer = new Signer();
        signer.setEmail("dijo@gmail.com");
        signer.setName("dijo francis");
        signer.setRecipientId("1");


        // create a |signHere| tab somewhere on the document for the signer to sign
        // here we arbitrarily place it 100 pixels right, 150 pixels down from top
        // left corner of first page of first envelope document
        SignHere signHere = new SignHere();
        signHere.setDocumentId("1");
        signHere.setPageNumber("1");
        signHere.setRecipientId("1");
        signHere.setXPosition("100");
        signHere.setYPosition("150");

        // can have multiple tabs, so need to add to envelope as a single element list
        List<SignHere> signHereTabs = new ArrayList<SignHere>();      
        signHereTabs.add(signHere);
        Tabs tabs = new Tabs();
        tabs.setSignHereTabs(signHereTabs);
        signer.setTabs(tabs);

        // add recipients (in this case a single signer) to the envelope
        envDef.setRecipients(new Recipients());
        envDef.getRecipients().setSigners(new ArrayList<Signer>());
        envDef.getRecipients().getSigners().add(signer);

        // send the envelope by setting |status| to "sent". To save as a draft set to "created" instead
        envDef.setStatus("sent");

        try
        {
            // instantiate a new EnvelopesApi object
            EnvelopesApi envelopesApi = new EnvelopesApi();
            // call the createEnvelope() API
            EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope("46e16c10-69f0-4258-b1ff-1ab5c61f2619", envDef);
            System.out.println("Envelope has been sent to " + signer.getEmail());
            System.out.println("EnvelopeSummary: " + envelopeSummary);
        }
        catch (com.docusign.esign.client.ApiException ex)
        {
            System.out.println("Exception: " + ex);
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...