Skip to content
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

INVALID_CONTENT_TYPE when creating an envelope #57

Closed
ihteandr opened this issue Apr 6, 2015 · 2 comments
Closed

INVALID_CONTENT_TYPE when creating an envelope #57

ihteandr opened this issue Apr 6, 2015 · 2 comments

Comments

@ihteandr
Copy link

ihteandr commented Apr 6, 2015

I want create the envelop but get this
'{\r\n "errorCode": "INVALID_CONTENT_TYPE",\r\n "message": "Content Ty
pe specified is not supported."\r\n}' }
this is the code
var CRLF = '\r\n';
var form = new FormData();
var filename = "test.pdf";
var documentId = Date.now();
var recipientId = settings.accountID;

    var json_data_options = {
        header: CRLF + '--' + form.getBoundary() + CRLF + 'Content-Type: application/json' + CRLF
    };
    for(var key in args.signers){
        args.signers[key].recipientId = recipientId;
    }
    var json_data = {
        "status":"sent",
        "emailBlurb":"Test Email Body",
        "emailSubject": "Test Email Subject - EnvelopeDefFull",
        "documents": [{
            "name": filename,
            "documentId": documentId,
            "order":"1"
        }],
        "recipients": {
            "signers" : args.signers
        }
    };
    form.append("form-data", JSON.stringify(json_data), json_data_options);

    var file_options =  {
        header: CRLF + '--' + form.getBoundary() + CRLF + 'Content-Type: application/pdf' + CRLF
    };
    form.append('file: filename="' + filename + '";documentId='+ documentId, args.file, file_options);

    var options = {
        method: "POST",
        uri: settings.baseUrl + "/accounts/" + settings.accountID + "/envelopes",
        headers: {
            "X-DocuSign-Authentication": JSON.stringify({
                Username: settings.username,
                Password: settings.password,
                IntegratorKey: settings.integrationKey
            }),
            "Accept": "application/json",
            "Content-Type": "multipart/form-data; boundary=" + form.getBoundary()
        },
        form: form
    };
    return new Promise(function(resolve, reject){
        request(options, function(error, response, body){
            if (!error && response.statusCode == 200) {
                resolve(JSON.parse(body));
            } else {
                error = {
                    error: error,
                    response: response,
                    body:body
                };
                reject(error);
            }
        });
    });

what can be a problem?
I try add the accountID into headers but it doesn't help

@jondkinney
Copy link
Owner

@ihteandr Sorry for the late reply. Are you using the version from rubygems? Or the master branch? I need to get a new gem version pushed to rubygems, but in the mean time if you point to the master branch in your Gemfile, does this same error still happen?

@recurrence
Copy link

This seems stale at this point, recommend close.

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

3 participants