Bad Request While Trying to create transient document in adobe using REST API

980 views Asked by At

I am trying to create a transient document in adobe sign using rest api.Foloowing is my code snippet:

        Http h = new Http(); 
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://api.in1.echosign.com/api/rest/v6/transientDocuments');
        req.setMethod(postMethod); 
        req.setHeader('Content-Type', 'application/json');
        blob testFileContent = blob.toPDF('test string it is'); 
       // req.setBody('{"filename":"testsign","file":'+testFileContent+'}');
        req.setBody('{"fileName":"testsign","file":"'+testFileContent+'"}');
        String authorizationHeader = 'Bearer ' +acceessToken;
        req.setHeader('Authorization', authorizationHeader); 
        //req.setHeader('Authorization', acceessToken);
        try{
            HttpResponse res = h.send(req);

However I am getting the bad request error in response.Issue maybe due to the tag mismatch with adobe sign requirement, however after a lot of research and trial and error I am not able to find the accurate tags to put in JSON for this API request. Any suggestion and help ?

1

There are 1 answers

0
bazinga On

Form data

Content-Disposition: form-data; name="File"; filename="<filename>.pdf"
Content-Type: application/pdf

Request params

Content-Type: multipart/form-data;
Accept: application/json, text/javascript, */*;

More details available in the documentation.