Open MrAta opened 5 years ago
I know that the reply is too late. Hopefully, the reply will help others visit this issue.
The most easy way to compose a request is use the proxy recorder.
Here is the request generated by the proxy recorder:
<request>
<http url='/api/Files/Upload' version='1.1' contents_from_file='~/.tsung/tsung_recorder20200811-1343-1.bin'
content_type='multipart/form-data; boundary=----WebKitFormBoundaryXmxIzOC6w2Vonz83' method='POST'>
<http_header name='Accept' value='*/*'/>
<http_header name='Accept-Encoding' value='gzip, deflate'/>
<http_header name='Accept-Language' value='en-US,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,zh;q=0.6'/>
<http_header name='X-Requested-With' value='XMLHttpRequest'/>
</http>
</request>
And the tsung_recorder20200811-1343-1.bin
file:
$ head -n 13 ~/.tsung/tsung_recorder20200811-1343-1.bin
------WebKitFormBoundaryXmxIzOC6w2Vonz83
Content-Disposition: form-data; name="targetPath"
result
------WebKitFormBoundaryXmxIzOC6w2Vonz83
Content-Disposition: form-data; name="thumbnailSize"
300
------WebKitFormBoundaryXmxIzOC6w2Vonz83
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: image/png
�PNG
The form data targetPath
and thumbnailSize
are used by my application. I just leave it here without modification. You can see that contents_from_file
points to the file that contains the body of the HTTP request.
I'm trying to send an image as part of my POST request, but I'm getting 400 status code from the server-side. I tried to copy the content of the image into a file and then using
contents_from_file
attribute, but it's not working.Here is my request specification:
The
imgdata
file content is like this:file=<the rest is the content of image file>
Is there any other way that I can send an image using a PSOT request?