Sathish
Sathish

Reputation: 360

Unable to upload zip file through karate framework

I am trying to upload a zip file through karate framework using the stack overflow reference: put-requests-to-upload-a-file-in-form-data-using-karate and karate documents upload.feature

Please find the code below:

Given path 'upload'
And header Content-Type = 'application/zip'
And multipart file code = { read: 'file:tests/create/export.zip', filename:'export.zip', contentType: 'application/zip' }
When method POST
Then status 200

We are getting the error as httpStatusCode="500"><links/><message>No ZIP data entries were found to import.</message>

Upvotes: 2

Views: 996

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

When you use multipart file you don't set the Content-Type, and it will default to multipart/form-data. Which is most likely what you want - but no one will be able to tell without details about your server.

Work with someone from your server-side team if needed to resolve this. Or edit your question with a cURL command that works and maybe we can figure out what you are doing wrong. Before that, please refer to this answer on how you can troubleshoot multipart in Karate if you have a cURL command that already works: https://stackoverflow.com/a/78547136/143475

There is a step by step process given here to help you get multi-part requests working, but it requires you to spend some time: https://github.com/karatelabs/karate/issues/1645#issuecomment-862502881

Also search for other answers on Stack Overflow: https://stackoverflow.com/search?q=%5Bkarate%5D+multipart

Else please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Upvotes: 1

Related Questions