Open AcousticDeveloper opened 8 months ago
A new content-type needs to be added but in UI it can be done in two ways:
x-www-form-urlencoded
in content type dropdown. Users will be able to add text fields and select only files containing text data and tells user to switch to multipart/form-data
whenever a file with binary content (image, video, etc) is selected.x-www-form-urlencoded
and can be toggled to multipart. It will be more intuitive and require less changes in the model. Users will be able to explicitly switch to multipart. It can also automatically switch to multipart whenever a file with binary content (image, video, etc) is selected by the user.@ashitaprasad I would like to give it a try
Sure @himanshugoyal77 you can give it a try. It will be assigned once you send across a PR.
Without this can't use it for getting access tokens for OAuth.
@ilovefreesw You can use this for getting access tokens for OAuth Just set the field type as String for form data fields
Describe the bug/problem Currently whenever the formdata is selected as request body, the
Content-Type
header is set tomultipart/form-data
but this should be dependent upon whether there is a file being uploaded too or else it can be set to the defaultapplication/x-www-form-urlencoded
.Relevant References stackoverflow: application/x-www-form-urlencoded or multipart/form-data? baeldung: Difference Between form-data, x-www-form-urlencoded and raw in Postman
Steps to Reproduce the bug/problem Select POST request in the request method, select formdata as the request body, add only text fields as fields, and then we can either chck the codegen for languages where Content-Type is printed, or else we can print
requestModel.requestBodyContentType.header
inside codegen files to check the request header.Expected behavior If there aren't any files uploaded i.e. all the fields are of text type and selected type is formdata, then the
Content-Type
should be set toapplication/x-www-form-urlencoded
, and if there is at least one file in the form data, then theContent-Type
should bemultipart/form-data
. As the defaultContent-Type
for HTML form submission isapplication/x-www-form-urlencoded
, hence it is worth introducing in API dash.Reference: Mozilla Documentation
Fixing this should start from introducing a new sub-type inside
consts.dart
file and then creating a newContentType
for the new type and setting up the Content Type based on whether there are any files associated with the request or not. Below are some code snippets fromconsts.dart
which are to be modified to start working on this issue.Device Info (The device where you encountered this issue):