Content-Type not being able to pass due to "-" in request header.
This is occurring from headers.js file and when function () is being called.
-unknown-:6 - javascript evaluation failed: read('classpath:headers.js'), javascript evaluation failed: function()
{return{requesting_app_name: 'ABC', Content-Type = 'application/json', app_key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
}
},
{return{requesting_app_name: 'ABC', Content-Type = 'application/json', app_key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
^ in
Version 0.9.0
It works perfectly if i pass this in * configure headers = { TrackingId: 'SomeValue', Token: 'AnotherValue' }.
Bascially the function method doesn't work if there is a "-" in Content-Type
@sadiqkassamali : If i understand your query correctly, you are unable to send 'Content-Type' in headers. So please use Content-Type in string quotes since it has a special character in it
refer -> https://github.com/intuit/karate#headers.
Try with
function()
{return{'requesting_app_name': 'ABC', 'Content-Type' : 'application/json', 'app_key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
}
Note: You don't need to mention header { 'Content-Type': 'application/json' } since karate automatically appends it to your request headers
No luck, now it's expecting a comma
-unknown-:6 - javascript evaluation failed: read(classpath:headers.js),
read(classpath:headers.js)
^ in
function()
{return{'requesting_app_name': 'ABC', 'Content-Type' = 'application/json', 'app_key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
}
}
You are using 'Content-Type' = 'application/json', try 'Content-Type' : 'application/json'. If it doesn't work, please attach your sample project here.
That did that trick, thanks for fresh eyes.
Most helpful comment
That did that trick, thanks for fresh eyes.