Sending multipart/form-data
See original GitHub issueI’m attempting to send a rather simple test to a server that requires post requests to be sent as multipart/form-data, however I am receiving an error when attempting to send the request. Error below:
TypeError: post() takes at most 4 arguments (5 given)
The code written is rather simple and I believe it follows all of locust’s requirements, however I am not sure why the error is occurring as my post only has 4 arguments. Code below:
from locust import HttpLocust, TaskSet, task
files = [
('front', ('image_front.jpg', open('image_front.jpg', 'rb'), 'image/jpeg')),
('back', ('image_back.jpg', open('image_back.jpg', 'rb'), 'image/jpeg'))]
class MyTaskSet(TaskSet):
@task
def image(i):
i.client.post("/tji8setj", files=files)
class MyLocust(HttpLocust):
task_set = MyTaskSet
min_wait = 5000
max_wait = 15000
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to send multipart/form-data request using Postman [closed]
UPDATE: I have created a video on sending multipart/form-data requests to explain this better. Actually, Postman can do this. enter image description here....
Read more >How to Multipart File Upload Using FormData with HTML | refine
A multipart request is a HTTP request that HTTP clients construct to send files and data over to a HTTP Server. It is...
Read more >Upload Data using Multipart. <form action ... - Medium
The enctype attribute specifies how the form-data should be encoded when submitting it to the server. Multipart/form-data is one of the most used ......
Read more >Using FormData Objects - Web APIs | MDN
The FormData object lets you compile a set of key/value pairs to send using XMLHttpRequest. It is primarily intended for use in sending...
Read more >Uploading File From a Web Page Using Multipart Form POST
Specify enctype="multipart/form-data" attribute on a form tag. · Add a name attribute to a single input type="file" tag. · DO NOT add a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bruceadams That seems to have done the trick as far as sending as multi-part is concerned, thanks! However I did notice that the files seem to get corrupted at some point during the request but I’m not sure if that’s a product of how the request is being sent, or if it has something to do with setting an improper boundary. I edited my original post with the boundary I set, but am not sure if it is correct.
I am also facing same issue my image file is getting corrupted…