cygne
cygne

Reputation: 547

How to put parameters in JSON in feature (karate framework)?

I would like to send my parameters from:

* def d = call read ('datas.json')

in my method in js file:

* header Authorization = call read('basic-auth.js') { username: 'd.usn', password: 'd.pw' } 

(assuming that in datas.json I have usn and pw)

instead of writing parameters 'john' and 'secret'

* header Authorization = call read('basic-auth.js') { username: 'john', password: 'secret' }

I'm sorry if I didn't find the information in official repo, but any answer would be very helpful: I needed this several times and didn't find an issue.

Upvotes: 1

Views: 1531

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58128

You make me worry that the Karate documentation is useless :P. Did you look at Embedded Expressions ?

Authorization = call read('basic-auth.js') { username: '#(d.usn)', password: '#(d.pw)' } 

By the way if datas.json was already in the form : { username: 'john', password: 'secret' }, you could do this:

Authorization = call read('basic-auth.js') read('datas.json')

Upvotes: 1

Related Questions