admin管理员组

文章数量:1353117

I'm using the Python requests library to implement the Zoho Sign document creation method shown here: .html

I'm using the following code:

import requests

requests.post('', {
    'requests': {
        'request_name': 'My Signing Request',
        'expiration_days': 18,
        'email_reminders': True,
        'reminder_period': 5,
        'notes': '',
        'is_sequential': True,
        'actions': ACTION_ARRAY,
    }
}, files={
    'file': FILE_IN_BYTES
})

Instead of a success response, I get the following error:

{"code":9015,"error_param":"requests","message":"Extra key found","status":"failure"}

Not sure what's going on here, as I'm passing their sample data in my request, and it doesn't seem to recognize it. I've tried passing the data as json via "json=", which silences the error, but then everything I pass over is ignored. Any ideas?

I'm using the Python requests library to implement the Zoho Sign document creation method shown here: https://www.zoho/sign/api/document-managment/create-document.html

I'm using the following code:

import requests

requests.post('https://sign.zoho/api/v1/requests', {
    'requests': {
        'request_name': 'My Signing Request',
        'expiration_days': 18,
        'email_reminders': True,
        'reminder_period': 5,
        'notes': '',
        'is_sequential': True,
        'actions': ACTION_ARRAY,
    }
}, files={
    'file': FILE_IN_BYTES
})

Instead of a success response, I get the following error:

{"code":9015,"error_param":"requests","message":"Extra key found","status":"failure"}

Not sure what's going on here, as I'm passing their sample data in my request, and it doesn't seem to recognize it. I've tried passing the data as json via "json=", which silences the error, but then everything I pass over is ignored. Any ideas?

Share Improve this question edited Apr 1 at 6:15 VLAZ 29.1k9 gold badges63 silver badges84 bronze badges asked Mar 31 at 19:33 meesterguypersonmeesterguyperson 1,8841 gold badge22 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

So as it turns out, Zoho Sign requires a mish-mash of formats in order for the request data to register correctly, which is not entirely clear from the documentation. The following will result in a successful call:

import json
import requests

requests.post('https://sign.zoho/api/v1/requests', {
    'data': json.dumps({'requests': {
        'request_name': 'My Signing Request',
        'expiration_days': 18,
        'email_reminders': True,
        'reminder_period': 5,
        'notes': '',
        'is_sequential': True,
        'actions': ACTION_ARRAY,
    }})
}, files={
    'file': FILE_IN_BYTES
})

Because the file must be sent as multipart-encoded form data, everything else has to be fit into the "data" field as json-encoded data. Submitting it as non-json-encoded data will result in an error.

So to answer the original question, the reason for the "Extra key found" message is that Zoho is expecting to receive a "data" key and only a "data" key containing the request data. When it saw the "requests" key instead, this registered as an extra and unwanted key. Hence the message.

本文标签: