-
Notifications
You must be signed in to change notification settings - Fork 358
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
Content-Type missing in Python Requests code generated for file upload of image #247
Comments
Just a quick nitpick as i am just checking out this issue because of a similar problem with the codegenerator for Python Requests. You have generated a GET request and not a POST, I do not think it is a big issue, but just informing as I saw the answer is recent and it would be good to fix it it before it creates more hassles |
Wow! The old code generator works like a charm! Do you want me close this issue or you guys are fixing in new code gen? |
Currently me and @dasyad00 have made a pull request that may fix the new code generator issue as we also had some problems with it. |
Let it be here. The maintainers will close it. |
@benjose22 Can you tell me exactly which request was giving an error ? I am not able to reproduce it now ? |
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](https://user-images.githubusercontent.com/56347659/82015289-0ae3fe80-969c-11ea-93c5-64e38e706539.png)
The text was updated successfully, but these errors were encountered: