POST REQUEST用于在DocuSign中创建信封

时间:2017-12-29 09:32:29

标签: wordpress api docusignapi

这就是我现在所拥有的一切。我正在使用jQuery 我也收到此错误: PARTNER_AUTHENTICATION_FAILED

jQuery(document).ready(function($){
    // console.log('DocuSign Script Loaded!');

    var accountId = '404569';

    // on button click
    $('#upload_submit').click(function(){

        // form inputs
        // document, emailSubject, status, recipients
        var name = $('#upload_name').val();
        var email = $('#upload_email').val();

        $.post("https://na2.docusign.net/restapi/v2/accounts/" + accountId + "/envelopes", {

        },  
        function (data) {
            console.log(data);
        });
    });
});

2 个答案:

答案 0 :(得分:0)

您的示例代码未提供身份验证凭据。

答案 1 :(得分:0)

<?php
    // Set Authentication information
    $email = '';
    $password = '';
    $integratorKey = '';

    function get_url( $email, $password, $integratorKey ) {
        // api service point
        $url = "https://demo.docusign.net/restapi/v2/login_information";

        // construct the authentication header:
        $header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

        // STEP 1 - Login (to retrieve baseUrl and accountId)
        $curl = curl_init( $url );
        curl_setopt( $curl, CURLOPT_HEADER, false );
        curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
        curl_setopt( $curl, CURLOPT_HTTPHEADER, array( "X-DocuSign-Authentication: $header" ) );

        $json_response = curl_exec( $curl );
        $status = curl_getinfo( $curl, CURLINFO_HTTP_CODE );


        if ( $status != 200 ) {
            return (['ok' => false, 'errMsg' => "Error calling DocuSign, status is: " . $status]);
        }

        $response = json_decode( $json_response, true );

        // Account ID and Base URL for envelopes API
        $accountId = $response["loginAccounts"][0]["accountId"];
        $baseUrl = $response["loginAccounts"][0]["baseUrl"];

        curl_close( $curl );

        return $baseUrl;
    }

    // Base URL Envelope
    $baseUrl = get_url( $email, $password, $integratorKey );