Skip to main content
Participant
November 15, 2018
Answered

Sending MS Word Document in multipart/form data request

  • November 15, 2018
  • 3 replies
  • 4991 views

Hi,

I am working on a POC where I need to send word document to Transient Document API using REST call. Bellow is the request which I am sending.

----AdobeSignApiboundary
Content-Disposition: form-data; name="File-Name"
Sample_Letter.doc

----AdobeSignApiboundary
Content-Disposition: form-data; name="Mime-Type"
application/msword

----AdobeSignApiboundary
Content-Disposition: form-data; name="File"; filename="Sample_Letter.doc"
ContentType: application/msword
Content-Transfer-Encoding: binary
�� ࡱ �> ��   j l ����i��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������   � �  �  bjbj � �   7 }��c}��c ,�� �� �� �~ ~ � � � � �  ����� � � 8   %  � � l 9 9 9 9 9 m m m y  { { { { { { $f �   t�  � m m m m m � � � 9 9 4 �  � � � m F� 9 � 9 y � m y � � � 9 �����mc��|� ����� F� e  � 0� � � � ^� � � � � �m m � m m m m m � � W Fm m m � m m m m ��������������������������������������������������������������������� m m m m m m m m m ~

� :       

Sample Letter
 


     

l�l�l� �

      
   * , . 0 2 4 8 : > @ D F J L N Z \ ^ ` ����˼˯����������~ufYL?  h� �OJQJmH nH u    h ~ OJQJmH nH u    h�?�OJQJmH nH u    hB ?5 �OJQJmH nH u    h�?�mH nH u    j hJw� h�?�U  mH nH u    h� Y  j h� YU    h
~YOJ QJ ^J   h� �OJ QJ ^J   h�x  h�E�OJ QJ ^J   h�x  h�x CJ(OJ QJ ^J   h�x OJ QJ ^J   hmsjB* OJ QJ ^J ph  hNK�B* OJ QJ ^J ph  h�I�B* OJ QJ ^J ph         
     , 2 6 8 < > B D H J N \ �������������������
  ��  �^�� gd� �   �gdB ?   d�  �gd�?�

����   �F Microsoft Word 97-2003 Document
MSWordDoc Word.Document.8�9�q

----AdobeSignApiboundary--

but the response I am getting from Adobe is

{     "code": "NO_FILE_CONTENT",     "message": "Must provide file body" }

I am not sure where is the problem.

This topic has been closed for replies.
Correct answer romainl745608

Hi pavanin617226,

I don't know if this code can help you , but i post my solution (which works with pdf) :

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="File-Name"

FileName

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="Mime-Type"

MimeType

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="File"; File-Name="'+ FileName + '"

Content-Type:  MimeType

Content-Transfer-Encoding: base64

YourPDF

------WebKitFormBoundary7MA4YWxkTrZu0gW--

3 replies

romainl745608
romainl745608Correct answer
Participating Frequently
November 16, 2018

Hi pavanin617226,

I don't know if this code can help you , but i post my solution (which works with pdf) :

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="File-Name"

FileName

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="Mime-Type"

MimeType

------WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name="File"; File-Name="'+ FileName + '"

Content-Type:  MimeType

Content-Transfer-Encoding: base64

YourPDF

------WebKitFormBoundary7MA4YWxkTrZu0gW--

Participant
November 16, 2018

Thanks for sharing your code, will try this and let you know.

Additionally whenever there was a success while sending the document, even though the document is not 100 pages, I get an email saying Page limit has exceeded.

Participant
November 19, 2018

Hi romainl745608,

I tried the above code with base64 encoding, but initially it was giving same error as "No File Content"

After a lot of debugging, we have found that instead of one we have to add two ""CRLF"  after the "Content-Transfer-Encoding" header.

We tried for both doc (application/msword) and docx files and its working fine.

Bellow is the working code:

------WebKitFormBoundary7MA4YWxkTrZu0gW + CRLF

Content-Disposition: form-data; name="File-Name" + CRLF

FileName + CRLF+ CRLF

------WebKitFormBoundary7MA4YWxkTrZu0gW + CRLF

Content-Disposition: form-data; name="Mime-Type" + CRLF

application/vnd.openxmlformats-officedocument.wordprocessingml.document + CRLF + CRLF

------WebKitFormBoundary7MA4YWxkTrZu0gW + CRLF

Content-Disposition: form-data; name="File"; File-Name="'+ FileName + '" + CRLF

Content-Type:  application/vnd.openxmlformats-officedocument.wordprocessingml.document + CRLF

Content-Transfer-Encoding: base64 + CRLF + CRLF

base64 docx content + CRLF + CRLF

------WebKitFormBoundary7MA4YWxkTrZu0gW--

Thank you for your help.

romainl745608
Participating Frequently
November 16, 2018

Hi pavanin617226,

If you receive a base64 encoded file, why you don't send directly your file in base64 without decode it like that :

----AdobeSignApiboundary
Content-Disposition: form-data; name="File-Name"
Sample_Letter.doc

----AdobeSignApiboundary
Content-Disposition: form-data; name="Mime-Type"
application/msword

----AdobeSignApiboundary
Content-Disposition: form-data; name="File"; filename="Sample_Letter.doc"
ContentType: application/msword
Content-Transfer-Encoding: base64

yourfile

Regards,

Romain.

Participant
November 16, 2018

Hi romainl745608,

I tried with sending base64 file contents as above mentioned but still received the same "No File Content" response.

For docx files also, I am able to send some files but receiving error for others, all are Word 2016 files.

romainl745608
Participating Frequently
November 15, 2018

Hi pavanin617226,

Your request seems correct, did you encode this request and set it to the body ?

Regards,

Romain.

Participant
November 16, 2018

Hi romainl745608,

The input we are receiving is base64 encoded file. We are custom creating above multipart request with decoded file content and sending it as is in body.

I am able to send docx file with  Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document but getting above issue with doc files