Home > Enterprise >  Send a POST method using a CSV as form-data Karate Framework
Send a POST method using a CSV as form-data Karate Framework

Time:12-01

I need to implement this request in Karate:

curl --location --request POST 'https:/myURL/' \
--header 'Authorization: Bearer myToken' \
--form 'csv=@"newUser.csv"'

PS: newUser.csv file is in the same folder as my feature

This is how I am sending my request on Postman:

Error message

Which will be the case when I not attached the csv file or use a file with different extension:

Postman

And this is how it looks the request on Karate logs:

Postman

It seems I am not sending anything as a body after the conversion to string

CodePudding user response:

Make this change:

* def fileContents = karate.readAsString('classpath:newUser.csv')
* multipart file csv = { value: '#(fileContents)' }

Refer: https://github.com/karatelabs/karate#csv-files

  • Related