1

I'm trying to upload an .xlsx file using Karate and after dozens of hours spent on that.. I give up.

Given url 'http://example.com'
* multipart file file = { read: 'this:testFile.xlsx', filename: 'testFile.xlsx', contentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }
* header Content-Type = 'multipart/form-data'
When method post
Then status 200

Here is a piece of code I'm using. This is one of hundreds versions of it, but I'm putting just this one, because every time the result is the same. Uploaded file has 0 B size...

I have read and applied suggestions from all over the internet (of course including examples from Karate docs) and each and every time I have exaclty the same result - 0 byte file on the server.

In a few of threads here, I saw comments that for 'thousands' of Karate users it works, so I'm kindly asking one of you to share some real-world working example of successfull .xlsx file upload.

PS. I'm uploading exactly the same file using JMeter and Postman, and it works fine.

  • update your question with a cURL command that works. else please feel free to drop karate and use P*stman :P – Peter Thomas May 19 '21 at 15:39
  • Heh, @PeterThomas, I knew you will answer in such a sarcastic way :) I don't want to drop Karate, as I found it very useful tool. I just added a comment about JMeter and P..man, because it's not a server or file related issue. I'm just asking for help and for some working example to see what probably I'm doing wrong or missed anything. Anyway.. thanks in advance to anyone who would like to help actually.. – pixi_edward May 19 '21 at 15:56
  • I wanted to help, which is why I asked for a cURL command. but no worries, all the best – Peter Thomas May 19 '21 at 16:50
  • Why are you using excel files for testing? I know this isn't what you're looking for, but it's often better to use fresh data via a db connection or api response. From there you can save that data in test context, or send it to a file stored in your repo. – anutter May 19 '21 at 16:56
  • 1
    @anutter Thanks for suggestions, but I need to include an upload in my test, as this is a crucial functionallity in my service. Don't want to go deeper in that, but believe me that in my case there is no other way, the xlsx file needs to be imported via API.. – pixi_edward May 20 '21 at 08:29
  • @PeterThomas, I downgraded Karate to 0.9.6 and the upload works fine. I didn't change anything in my code. So apparently there is an issue with the latest versions of Karate (I tested 1.0.0, 1.0.1 and 1.1.0.RC1) – pixi_edward May 20 '21 at 09:50
  • @pixi_edward oh that is quite likely. would you mind following this process ? if not, you may need to remain on old versions for a while: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas May 20 '21 at 10:01

1 Answers1

2

If you can do it with Postman, you can have Postman convert your query to a curl command to aid in troubleshooting: enter image description here