• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

error when creating an agreement based on a templateid (embedded signing)

New Here ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Hi,

I am a new user (Developer) of Adobe Sign (in live trial).

I can't figure out why I get this error:
{'code': 'BAD_REQUEST', 'message': 'The request provided is invalid'}
Error creating agreement: {"code":"BAD_REQUEST","message":"The request provided is invalid"}

 

I can not see what is wrong on my create_agreement_data

 

# create_send_embedded_signing.py
import requests

access_token = 'dummy123'
template_id = '3AAABLblqZhCvWrW4m3sV4GADuaPQ1duSivAJktzzZaTS2VMonxHZ-h57ULZHquwWO'

# Replace these values with your own
email = 'abc@gmail.com'
role = 'SIGNER'

base_url = 'https://api.na1.adobesign.com/api/rest/v2'

headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json'
}

# Create an agreement using the template
create_agreement_data = {
    "fileInfos": [
        {
            "libraryDocumentId": template_id#,
            #"transientDocumentId": transient_doc_id,}

        }
    ],
    'name': 'Agreement created from a template via API from Castilleja',
    'participantSetsInfo': [
        {
            'order': 1,
            'role': role,
            'memberInfos': [
                {
                    'email': email
                }
            ]
        }
    ],
    'signatureType': 'ESIGN',
    'state': 'IN_PROCESS'
}

response = requests.post(f'{base_url}/agreements', json=create_agreement_data, headers=headers)
agreement = response.json()
print(agreement)

 

 

TOPICS
Acrobat Sign , Acrobat Sign Developer , Adobe Sign , Adobe Sign Developer , Automate signing , Sign SDK

Views

361

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 12, 2023 Apr 12, 2023

Copy link to clipboard

Copied

While it's not strictly necessary, I'd use json as well.

 

Try this?

 

 

import requests
import json

url = "https://api.nat.adobesign.com/api/rest/v6/agreements"

payload = json.dumps({
  "fileInfos": [
    {
      "libraryDocumentId": "{{LibDocID-Here}}"
    }
  ],
  "name": "API Send Library Test Agreement 607",
  "participantSetsInfo": [
    {
      "memberInfos": [
        {
          "email": "{{signer email}}"
        }
      ],
      "order": 1,
      "role": "SIGNER",
      "name": "test signer1"
    }
  ],
  "message": "Plese sign this from us.",
  "signatureType": "ESIGN",
  "externalId": {
    "id": "NA2Account_1681310111"
  },
  "state": "IN_PROCESS"
})
headers = {
  'x-api-user': 'email:{{env_adminEmail}}',
  'Content-Type': 'application/json',
  'Authorization': 'Bearer {{access_token_here}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

 

You can find more working example code in our public POSTMAN collection, here:
https://www.postman.com/adobe/workspace/adobe-acrobat-sign/request/24728226-c84096c3-8e46-4d43-9607-...

Aaron Smusz -Customer Enablement Engineer - Adobe Acrobat Sign

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 12, 2023 Apr 12, 2023

Copy link to clipboard

Copied

Thanks.


What is : 

 'x-api-user': 'email:{{env_adminEmail}}',


and 

"externalId": {
    "id": "NA2Account_1681310111"
  },

 

?  Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 12, 2023 Apr 12, 2023

Copy link to clipboard

Copied

LATEST

"x-api-user" is used to "impersonate" a user in the account IF your token is a group-scoped or account-scoped token. 

In many cases customers are building integrations where the sender/creator of an agreement on Sign needs to be the same as the person logged into the integrated platform/application.  In this case they may not want or need each user to have to go through getting their own oAuth token so they have a group admin or an account admin get a group or account scoped token.  Then the API calls can be made as-if the sender was logged into Sign as themselves.

 

I can make an API call using an account-scoped token that was acquired/owned by an account admin and put the email address of ANY other valid sender in that same account into the x-api-user param and I'm essentially impersonating that user for that agreement or other action as-if they had logged into the Sign web UI and sent it themselves.

The " 'externalId': " is a parameter you can use with the API call to us to create an agreement so that when you get a webhook, or poll agains that agreement ID  you will know that agreement belongs to a unique record in your application.  It's used to "connect the dots" between the agreement ID and the unique record ID from your application to which that agreement "belongs".

Hope this helps?

Aaron Smusz -Customer Enablement Engineer - Adobe Acrobat Sign

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines