[GH-ISSUE #898] When uploading form data, "copy curl" does not get the body #895

Closed
opened 2026-03-03 19:22:46 +03:00 by kerem · 7 comments
Owner

Originally created by @PangYenChen on GitHub (May 24, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/898

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

2.25.0 (22500)

macOS Version? (Ex. mac 10.14)

10.15.6(19G2021)

Steps to reproduce

Upload an image using form data format,
and Proxyman gui click "copy curl".

Expected behavior

Get the curl with form data format body.

Originally created by @PangYenChen on GitHub (May 24, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/898 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) 2.25.0 (22500) ### macOS Version? (Ex. mac 10.14) 10.15.6(19G2021) ### Steps to reproduce Upload an image using form data format, and Proxyman gui click "copy curl". ### Expected behavior Get the curl with form data format body.
kerem 2026-03-03 19:22:46 +03:00
Author
Owner

@NghiaTranUIT commented on GitHub (May 24, 2021):

Thanks for the bug report @PangYenChen. I'm able to reproduce the bug when uploading the file with multipart/form-data 👍

I'm going to fix it and send a BETA build this week 🌮

<!-- gh-comment-id:846681035 --> @NghiaTranUIT commented on GitHub (May 24, 2021): Thanks for the bug report @PangYenChen. I'm able to reproduce the bug when uploading the file with multipart/form-data 👍 I'm going to fix it and send a BETA build this week 🌮
Author
Owner

@NghiaTranUIT commented on GitHub (May 24, 2021):

Hey @PangYenChen, there are two possible solutions:

cURL with the invalid body, but exact multipart/form-data

I tried to perform the "copy as a cURL" with Charles and Fiddler, and the result is:

curl -H 'Host: httpbin.org' -H 'user-agent: insomnia/2021.3.0' -H 'content-type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY' -H 'accept: */*' --data-binary "--X-INSOMNIA-BOUNDARY
Content-Disposition: form-data; name=\"file\"

proxyman.png
--X-INSOMNIA-BOUNDARY
Content-Disposition: form-data; name=\"body\"; filename=\"Screen Shot 2021-05-24 at 09.00.12.png\"
Content-Type: image/png

�PNG


IHDR� $9�PDiCCPICC Profile(�c``H,(�aa``��+)
rwR���R`��� ��� Π��\\��T��Q��k� ��.�,��\{'�x�!���Yɣݘ�QWJjq2���)�E%�	@�ryI��d�d���!�5 v�}�&$�Ⱦd$g$��O�l�$$�t$6�^�|�<\�L�	8�TP�ZQ���*�2�3J�!��������`d`d��
o��ρ�pd;��_��`񕁁yB,i&��V�[1�����v� �(��o,�i�F6����?�10�Of`�;���ߋ����h��y�ao��`��eXIfMM*>F(�iN����x��� ASCIIScreenshot�6�	pHYs%%IR$��iTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"XMP Core 6.0.0\">
   <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
      <rdf:Description rdf:about=\"\"
            xmlns:exif=\"http://ns.adobe.com/exif/1.0/\">
         <exif:PixelYDimension>288</exif:PixelYDimension>
         <exif:PixelXDimension>640</exif:PixelXDimension>
         <exif:UserComment>Screenshot</exif:UserComment>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>
I�c�iDOT�(��ưq��IDATx�ܱ� C���؉�/���?t����Z�� @�d���ZP @��0 @ &`�
� `� @�@L��.. @�t @����+\\ @��x��?�� 0Ce�J���� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @`�km @��ӵ� @��#`: @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @������@� �0;]KJ�8�C @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�@7@��	����%@��n� 0c��K��Z @�@G��t-) @��� 0c��K�0� @ &`�
� `� @�@L��.. @�t @����+\\ @��� @�10V�� @��
 @�b`�pq	 @�� @���X�� @�>��G���IDAT�ֱ�@A\
$��q�̷q��r���{� @ #0`�kA	 @�[�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @��>��@� �0;]KJ���G @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K��� @������ZR @��0= @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @���Ϸ0 @�t�Nג @���� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�@?@��	����%@��~� 0c��K�0� @ &`�
� `� @�@L��.. @�� @����+\\ @��� @�10V�� @�� @�b`�pq	 @�� @���X�� @�~�:�&n��IEND�B`�
--X-INSOMNIA-BOUNDARY--
" 'https://httpbin.org/post?name=proxyman'

It's exactly the request body, but when executing it on the Terminal, it yields the error (Invalid body).

Better cURL with -F option

From cURL Doc, we can use -F to make a correct multipart/form-data request.

curl 'https://httpbin.org/post?name=proxyman' \
-X POST \
-H 'User-Agent: insomnia/2021.3.0' \
-H 'Host: httpbin.org' \
-H 'Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY' \
-H 'Accept: */*' \
-F 'file=proxyman.png' \
-F 'body=@image.png'

You can execute this cURL on the Terminal app. However, it appends the boundary=------------------------4b3032089740ba4f automatically.


Just wondering, what scenario do you need? @PangYenChen 🤔

  1. Just a body like Charles/Fiddler
  2. Or a working cURL for multipart/form-data
<!-- gh-comment-id:846712038 --> @NghiaTranUIT commented on GitHub (May 24, 2021): Hey @PangYenChen, there are two possible solutions: ### cURL with the invalid body, but exact multipart/form-data I tried to perform the "copy as a cURL" with Charles and Fiddler, and the result is: ```bash curl -H 'Host: httpbin.org' -H 'user-agent: insomnia/2021.3.0' -H 'content-type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY' -H 'accept: */*' --data-binary "--X-INSOMNIA-BOUNDARY Content-Disposition: form-data; name=\"file\" proxyman.png --X-INSOMNIA-BOUNDARY Content-Disposition: form-data; name=\"body\"; filename=\"Screen Shot 2021-05-24 at 09.00.12.png\" Content-Type: image/png �PNG  ��� IHDR����� ���$9�P��DiCCPICC Profile��(�c``H,(�aa``��+) rwR���R`��� ��� Π��\\��T���Q��k � ��.�,��\{'�x�!���Yɣݘ�Q�WJjq2���)�E% � @�ryI��d�d����!�5 v�}��&$�Ⱦd $g$���O�l�$$�t$6�^�|�<\�L� 8�TP�ZQ��� *�2�3J�!��������`d`d��� o��ρ�pd;��_��`񕁁yB,i&��V�[1� ����v� �(���o,�i�F6����?�10�Of`�;���ߋ����h��y��ao��`�����eXIfMM�*�����������>�������F(��������i�������N����������������������������x��������������� ����ASCII���Screenshot�6���� pHYs��%��%IR$����iTXtXML:com.adobe.xmp�����<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"XMP Core 6.0.0\"> <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"> <rdf:Description rdf:about=\"\" xmlns:exif=\"http://ns.adobe.com/exif/1.0/\"> <exif:PixelYDimension>288</exif:PixelYDimension> <exif:PixelXDimension>640</exif:PixelXDimension> <exif:UserComment>Screenshot</exif:UserComment> </rdf:Description> </rdf:RDF> </x:xmpmeta> I�c����iDOT��������������(����������ưq����IDATx�ܱ� C���؉�/���?t����Z�� @��d���ZP @��0� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��x��?��� 0�Ce�J��� ��� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @`�km  @���ӵ� @���#`�: @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @�������@�� �0�;]KJ��8�C @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @�� @7@��� ����%@���n�� 0�c��K���Z @�@G���t-) @���� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��t @�����+\\ @��� @��10V�� @���  @��b`�pq  @��� @��� �X�� @��>�����G�����IDAT�ֱ�@ A\ $��q�̷q��r���{�� @ #0`�kA  @��[��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @���>��@�� �0�;]KJ����G @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K���� @�������ZR @��0�= @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @���Ϸ0 @��t �Nג @����� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @�� @?@��� ����%@���~�� 0�c��K��0��� @ &`�� �� `�� @�@L���.. @��� @�����+\\ @��� @��10V�� @��� @��b`�pq  @��� @��� �X�� @��~�:�&n������IEND�B`� --X-INSOMNIA-BOUNDARY-- " 'https://httpbin.org/post?name=proxyman' ``` It's exactly the request body, but when executing it on the Terminal, it yields the error (Invalid body). ### Better cURL with -F option From cURL Doc, we can use `-F` to make a correct multipart/form-data request. ```bash curl 'https://httpbin.org/post?name=proxyman' \ -X POST \ -H 'User-Agent: insomnia/2021.3.0' \ -H 'Host: httpbin.org' \ -H 'Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY' \ -H 'Accept: */*' \ -F 'file=proxyman.png' \ -F 'body=@image.png' ``` You can execute this cURL on the Terminal app. However, it appends the `boundary=------------------------4b3032089740ba4f` automatically. -------------------- Just wondering, what scenario do you need? @PangYenChen 🤔 1. Just a body like Charles/Fiddler 2. Or a working cURL for multipart/form-data
Author
Owner

@PangYenChen commented on GitHub (May 24, 2021):

I want to upload an image to the server from a mobile app.

I need to tell my backend colleague what request the mobile app sent.

In general, the image file is not a local file on my computer.

So, the exact multipart/form-data will be better.

I am not a native English speaker. Please pardon me.

<!-- gh-comment-id:846905508 --> @PangYenChen commented on GitHub (May 24, 2021): I want to upload an image to the server from a mobile app. I need to tell my backend colleague what request the mobile app sent. In general, the image file is not a local file on my computer. So, the exact multipart/form-data will be better. I am not a native English speaker. Please pardon me.
Author
Owner

@NghiaTranUIT commented on GitHub (May 24, 2021):

Thanks for your clarification @PangYenChen 👍 I will follow this approach because it's easier to implement 😄

<!-- gh-comment-id:846968292 --> @NghiaTranUIT commented on GitHub (May 24, 2021): Thanks for your clarification @PangYenChen 👍 I will follow this approach because it's easier to implement 😄
Author
Owner

@NghiaTranUIT commented on GitHub (May 24, 2021):

@PangYenChen please check out this Beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.26.0_cURL_Multipart_Form_Data.dmg

It will fix your bug 👍

<!-- gh-comment-id:847074629 --> @NghiaTranUIT commented on GitHub (May 24, 2021): @PangYenChen please check out this Beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.26.0_cURL_Multipart_Form_Data.dmg It will fix your bug 👍
Author
Owner

@NghiaTranUIT commented on GitHub (May 25, 2021):

Meanwhile, I've implemented the multipart/form-data previewer at https://github.com/ProxymanApp/Proxyman/issues/833#issuecomment-847667322

Please check it out 😄 @PangYenChen

<!-- gh-comment-id:847667812 --> @NghiaTranUIT commented on GitHub (May 25, 2021): Meanwhile, I've implemented the multipart/form-data previewer at https://github.com/ProxymanApp/Proxyman/issues/833#issuecomment-847667322 Please check it out 😄 @PangYenChen
Author
Owner

@PangYenChen commented on GitHub (May 25, 2021):

Thanks a lot!

Though it works properly for my case, I think that generally “Better cURL with -F option” would be a better option for other people.

If there is a switch to toggle the result of “copy curl”, it would be perfect!

It’s just a suggestion.

Thanks again!

By the way, multipart/form-data previewer is amazing!

<!-- gh-comment-id:847766776 --> @PangYenChen commented on GitHub (May 25, 2021): Thanks a lot! Though it works properly for my case, I think that generally “Better cURL with -F option” would be a better option for other people. If there is a switch to toggle the result of “copy curl”, it would be perfect! It’s just a suggestion. Thanks again! By the way, multipart/form-data previewer is amazing!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#895
No description provided.