Skip to content

Content-Type missing in Python Requests code generated for file upload of image #247

@benjose22

Description

@benjose22

Describe the bug
Content-Type is mandate while sending POST request for image upload. Content-Type is missing while generating Python Requests code using Postman code generator. E.g. 'image/png' hs to be included for uploading PNG files.

To Reproduce
In Body, set form-data.
Set KEY as 'upload' (note that this is not relevernt to the issue. I am just trying to match the screenshot.). Choose File from the dropdown(default is Text)
Set value - choose a png image from you computer.
Genererate Python Requests code.
Try executing the python code. We get error as invalid PNG file.

Expected code snippet and corresponding request
Expected-
files = [('upload', ('png_image.png', open('png_image.png', 'rb'), 'image/png'))]
Current -
files = [
('upload', open('/C:/fileupload/png_image.png','rb'))
]

Screenshots
image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions