I am trying to upload files on Google Drive using JMETER but the uploaded file name is 'Untitled'. Google Drive API's Bearer token is used as Authorization in the 'HTTP Header Manager' with Content-Type 'multipart/related; boundary=boundaryname' but still files get uploaded with the filename 'Untitled'.

I am using method 'uploadType=multipart'. If I send file's path in the 'Files Upload' section and metadata json with uploaded file's name and Content-Type. In this case it uploads file with correct name and extension but file is corrupted.

If I send only file's path in 'Files Upload' section and I do not send any metadata json, then file is uploaded fine but its name is Untitled.

When I use text or csv file's data with metadata json in the body of http request then file is uploaded correctly with correct filename and extension.

Content-Type: application/json; charset=utf-8

"name": "my_filename.txt"

Content-Type: text/plain

Hi there, I am user101 and use jmeter.

Above body content will upload the file correctly with name my_filename.txt but I do not have always text or csv files to upload, I want to upload pdf, images, videos and document files whose path I need to mention in "Files Upload" section.

Please suggest procedure to upload any filetype correctly with its name and extension.

1 Answer 1


It looks like you need to manually construct your request body using multipart-related content-type and specifying a boundary to split parts entries.

Example request structure:

Content-Type: application/json; charset=UTF-8


JSON Metadata
Content-Type: file MIME type


File content

More information: Testing REST API File Uploads in JMeter

  • Thank you for your comment. I am using your mentioned parameters in the body and I tried to send png File content with the code"${__FileToString(/home/user/Desktop/d.png)}" below Content-Type. The file is created in the drive with correct name but it is corrupted. It cannot be opened. I am not able to send png, pdf or other filetype data. Please suggest where I am doing mistake. Jul 4, 2021 at 7:09
  • At least try removing quotation marks from the function. If it doesn't help I would suggest encoding the file to Base64 using __groovy( ) function like ${__groovy(new File('/home/user/Desktop/d.png').bytes.encodeBase64().toString(),)} and add Content-Transfer-Encoding: base64 to the part headers.
    – Dmitri T
    Jul 5, 2021 at 6:41
  • It solved the issue. Thank you for your time and prompt reply. Jul 6, 2021 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.