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

Multi-part requests: user should be able to set content-type for each part in a multi-part request. #1602

Open
ash-eng-spin opened this issue Feb 15, 2024 · 7 comments · May be fixed by #2121
Assignees
Labels
enhancement New feature or request

Comments

@ash-eng-spin
Copy link

ash-eng-spin commented Feb 15, 2024

When setting up a multipart request, Bruno automatically selects the content-type of the file part. The auto-assigned content-type is not always the desired content-type of the API spec, therefore our request will always result in a 400 Bad Request, because the content-type is wrong.

Please allow a way for the user to set the content type for a multi-part request part. File or text

Text/Param: user should be able to set because this could be blank, application/json, application/xml, text/plain or many other things.
Files: user should be able to set because this could be blank, application/pdf, application/octet-stream, application/vnd.ms-excel, text/csv or many other things.

Example: Multipart Form Data: PDF file content-type automatically set. No manual way for user to set content-type for a file.
Why is this a problem: API spec for the pdf file wants "application/octet-stream" for the content-type. Bruno automatically sets the content-type to "application/pdf". No way to manually set the content-type. Results in 400 bad request because content-type does not match API spec and there is no way to change in Bruno.

image

This appears to align with your plans to update the Bru Lang Schema #1502 but I want to make sure the user can set the content-type in the UI for params and files.

Versions

v1.9.0

Steps to reproduce 1

  1. Create POST request
  2. Go to Body
  3. Select Multipart Form
  4. Click Add Param
  5. Enter key and value <---User cannot change content-type of the file

Steps to reproduce 2

  1. Create POST request
  2. Go to Body
  3. Select Multipart Form
  4. Click Add File
  5. Enter key and select file<---User cannot change content-type of the file

For reference this is how it works in Postman:
image

@sanjai0py sanjai0py added the enhancement New feature or request label Apr 11, 2024
end3rbyte pushed a commit to end3rbyte/bruno that referenced this issue Apr 16, 2024
…r each part in a multi-part request (usebruno#1602)

If a parameter is a valid json, it automatically sets the Content-Type application/json for that parameter
@end3rbyte
Copy link
Contributor

Hi,

We have the same problem indeed especially for parameters in JSON format.
I sent a PR so that it detects when the parameter is in JSON format, and add Content-Type: application/json in this case.

@ddasol
Copy link

ddasol commented Apr 16, 2024

We are facing the same issue. This is the single feature missing so we can fully migrate to Bruno.
We need to send a file and a json in the same request.
It seems like @busy-panda 's PR could do the trick while we wait for a feature as suggested by @ash-eng-spin .

@ngujjari27
Copy link

We had the same issue. Hope the change provided by @busy-panda will be approved quickly.

@end3rbyte
Copy link
Contributor

Sorry I closed my PR because I prefer to fully implement as suggested by @ash-eng-spin, so I will add a column "Content-Type".

That will probably take more time.

@end3rbyte
Copy link
Contributor

end3rbyte commented Apr 18, 2024

The enhancement is fully implemented and the PR was created: #2121

end3rbyte pushed a commit to end3rbyte/bruno that referenced this issue Apr 18, 2024
end3rbyte pushed a commit to end3rbyte/bruno that referenced this issue Apr 18, 2024
end3rbyte pushed a commit to end3rbyte/bruno that referenced this issue Apr 25, 2024
commit cdf56fc
Merge: f27e79c 16861c9
Author: busy-panda🐼🐼 <[email protected]>
Date:   Wed Apr 24 11:47:07 2024 +0200

    Merge branch 'usebruno:main' into feature/1602-multipart-content-type

commit f27e79c
Merge: 40872f6 59ffb01
Author: busy-panda🐼🐼 <[email protected]>
Date:   Sat Apr 20 10:25:02 2024 +0200

    Merge branch 'usebruno:main' into feature/1602-multipart-content-type

commit 40872f6
Author: busy-panda <[email protected]>
Date:   Fri Apr 19 17:14:44 2024 +0200

    Reduced the width of the Operator column in tab Assert

commit b7f4eda
Author: busy-panda <[email protected]>
Date:   Fri Apr 19 17:08:38 2024 +0200

    Reduced the width of the Operator column in tab Assert

commit 8e99ed3
Author: busy-panda <[email protected]>
Date:   Fri Apr 19 17:06:49 2024 +0200

    moved assertions from Tests panel to Assert panel and

commit c3c91d6
Author: busy-panda <[email protected]>
Date:   Fri Apr 19 15:01:41 2024 +0200

    added placeholder support to MultiLineEditor component

commit 39f60da
Author: busy-panda <[email protected]>
Date:   Thu Apr 18 15:43:09 2024 +0200

    feature: Multi-part requests: user should be able to set content-type for each part in a multi-part request. usebruno#1602
@fskexp
Copy link

fskexp commented May 2, 2024

I had a case where I needed to send in a multi-part form a file item and a JSON item.
At first, I provided the JSON as a "Param" item. No content-type was automatically set for this form entry, so the request was rejected by my server.
Work-around: I passed the JSON as a JSON file and Bruno automatically set the content-type, so my server accepted the request.
I agree that being able to manually define the content-type of each item would be better.

@ddasol
Copy link

ddasol commented May 2, 2024

I had a case where I needed to send in a multi-part form a file item and a JSON item. At first, I provided the JSON as a "Param" item. No content-type was automatically set for this form entry, so the request was rejected by my server. Work-around: I passed the JSON as a JSON file and Bruno automatically set the content-type, so my server accepted the request. I agree that being able to manually define the content-type of each item would be better.

Thank you for sharing. I just tested and it worked for me as well.

Good option until we can manually/individually set the content-type.

@helloanoop helloanoop self-assigned this Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
7 participants