Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Send a multipart form-data request to the target service

I have an endpoint which accepts a xlsx file as multipart form-data request to be sent on target server. I have checked the trace and the request looks like below:

----------------------------553612111828308003453474 Content-Disposition: form-data; name="file"; filename="test.xlsx" Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet PK!{��!z�[Content_Types].xml �(����n�0E�����1tQU�E� �&�$�my ߉y��x(�M�؞{�Lf<��:YA@�l&i_$`s��-3�=��=�IY�jg!@1�� g�p��LTD�EJ�+h�΃�…F�Rz�/T ������z�j��� ��)y_�����X��nϵ�L(�k�+b�re�?H���A�|ٰt�>��XPS�>&�)qb(�Qf��AwY��ae<>p�'���vq_�;�ѐLT�O�p�r]�s��y����%Je���~<�2�76���/� �1��y��(s���o]�(z�\�zJܽ�� ��>�Gj�G��ݫ��6��Y8 ɱf;y�.;�w�ݕ�/�\s5~+s.�:���PK!^�e� _rels/.rels �(���MK1���!̽;�*"�l/E�Md�1��`7������FAt��z��w�y��f��x�{v�E ��fӻV�K����rF��H"l���3�*���>��⢄.%��uGVł=�\i8X�rZ�J�%\����P�4��H;s�>����67M�i�zoɥ#+��DΐY���B��5�V��$��~����"c'Z����k�RRF%������8���EsܙF|�0�2�Xn/ɢ�1�=c�W�7�޲���PK!�>����xl/_rels/workbook.xml.rels
----------------------------553612111828308003453474--

Now, i have a requirement to create another endpoint which accepts the JSON payload and transform it into the xlsx format and for that i have created a callout as well. I have also took some help from https://github.com/DinoChiesa/Apigee-Java-Simple-MultipartForm to create the multipart form-data request and now the request looks like below:

----------------------VT2NE72E0B9WGP Content-Disposition: form-data; name="test.xlsx"; filename="test.xlsx" Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet This is excel content ----------------------VT2NE72E0B9WGP--

I doubt that the request which i have prepared is not correct as the content inside it is not encoded as mentioned in the first trace. Kindly can someone tell me what i am missing out in this one so that it can work correctly.
Appreciate the help.

1 3 299
3 REPLIES 3