Santoshsarma
Santoshsarma

Reputation: 5667

PUT requests to upload a file in form data Using karate

I've tried to write equivalent karate script for below curl request

curl -X PUT \
  'http://localhost:8055/uploadfile' \
  -H 'content-type: multipart/form-data;' \
  -F code=@/Users/test/Downloads/Next.zip

Tried karate script

Given path 'uploadfile'
   #Given header Content-Type = 'multipart/form-data'
   And form field code = '/Users/test/Downloads/Next.zip'
   #And multipart file code =  { read: '/Users/test/Downloads/Next.zip' , contentType: 'application/zip' }
   When method PUT
   Then status 200

Am I doing something mistake here (tried different things)? Still not getting expected API response.

FYI : I've got that curl command from postman and it is working fine.

Upvotes: 1

Views: 1242

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

It is hard to tell with the limited info you have provided. Try this:

Given url 'http://localhost:8055/uploadfile'
And multipart file code = { read: 'file:/Users/test/Downloads/Next.zip', filename: 'Next.zip', contentType: 'application/zip' }
When method put

If you are still stuck follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue (or use postman ;)

Upvotes: 2

Related Questions