Unable to create envelopes using DocuSign API error: Object moved

Viewed 88

I want to create envelope using DocuSign API in my web application. When I run it in postman then response showing object move with html content This is my php code sample

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://account-d.docusign.com/v2.1/accounts/b15b77b0-9345-4780-bfc1-440b37991820/envelopes?change_routing_order=true',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "documents": [
        {
            "documentBase64": "Base64 code of my pdf file",
            "documentId": "5865888",
            "fileExtension": "pdf",
            "name": "test pdf"
        }
    ],
    "emailSubject": "test pdf",
    "recipients": {
        "signers": [
            {
                "name": "User full name",
                "email": "user@gmail.com",
                "recipientId": "8959555"
            }
        ]
    },
    "status": "send "
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: [{"key":"Authorization","value":"Bearer {{accessToken}}"}]'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

My API response is

Object moved to here.

Please guide me how to solve the issue

Thank You

1 Answers

That base URL is incorrect. Account-d.docusign.com is only for authentication.

Requests should be made to {SERVER}/restapi/v2.1

So for you it would be demo.docusign.net/restapi/v2.1/accounts/{ACCOUNT_ID/envelopes

Here's the dev centre article showing the whole process

Related