Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error raised when sending document if "expiration_date" is None, using SDK. #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dhruv-personal opened this issue Jun 27, 2024 · 0 comments

Comments

@dhruv-personal
Copy link

When using the SDK to send documents, an error is raised if "expiration_date" is None. This does not occur when using the requests library.

Example with SDK:

import pandadoc_client
from pandadoc_client.api import documents_api
from pandadoc_client.model.document_send_request import DocumentSendRequest

API_KEY = ""
DOCUMENT_ID = ""

cfg = pandadoc_client.Configuration(
    api_key={"apiKey": f"API-Key {API_KEY}"}"},
)
client = pandadoc_client.ApiClient(cfg)
documents_instance = documents_api.DocumentsApi(client)

document_send_request = DocumentSendRequest(silent=False, subject="This doc was sent via python SDK")
documents_instance.send_document(DOCUMENT_ID, document_send_request=document_send_request)

Raises:

pandadoc_client.exceptions.ApiTypeError: Invalid type for variable 'expiration_date'. Required value type is str and passed type was NoneType at ['received_data']['expiration_date']

Example with GET:

import requests

API_KEY = ""
DOCUMENT_ID = ""    # same template as the previous example

headers = {
    "Content-Type": "application/json",
    "Authorization": f"API-Key {API_KEY}"
}

url = "https://api.pandadoc.com/" + f"public/v1/documents/{DOCUMENT_ID}/send"
res = requests.get(url, headers=headers)
document_sent_response_dict = res.json()

Impact:

Because of this library behavior, I can't implement the feature of sending the document to the set of recipients defined during its creation using the SDK. Even though they receive the document, the method throws the below error:

{
    "message": "An unexpected error occurred.",
    "errors": "Invalid type for variable 'expiration_date'. Required value type is str and passed type was NoneType at ['received_data']['expiration_date']"
}

Steps to Reproduce:

  1. Set up the PandaDoc Python SDK using the API key and document ID.
  2. Create a document using a reference template with a set of recipients and send it with "expiration_date" as None, as it can't be set using the SDK.
  3. Observe the error raised by the SDK.

Expected Behavior:

The SDK should handle None values for fields that might be unknown or optional, similar to the behavior when using the requests library.

Actual Behavior:

The SDK raises an error when encountering None values for "expiration_date".

Environment:

  • Operating System: Ubuntu 20.04
  • Python Version: 3.11
  • PandaDoc Python SDK Version: 6.2.0
  • Additional Context: Handling None values gracefully in the SDK would improve its usability and prevent unexpected errors, aligning its behavior with direct API calls using the requests library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant