Will try to be precise in asking question. Sorry if couldn't do it up to the mark!
Was given an assignment to automate api from the given below link
https://restful-booker.herokuapp.com/apidoc/index.html
Using the Api chaining I am suppose to automate "Update booking" api by first generating token from "Create Token" api and passing it in headers for authorization. I checked it on postman its working fine there for karate I wrote this code
* def auth_token = response.token
Given url 'https://restful-booker.herokuapp.com/booking/5591'
* def request_header = { Accept: '*/*' , Accept-Encoding : 'gzip, deflate, br' , Connection : 'keep-alive', Content-Type : 'application/json' , Accept : 'application/json' , Cookie : 'token=' + auth_token }
the variable auth_token is getting token from the first api response and under same scenario I am trying to run update api by using above headers but it keeps giving this error
net.minidev.json.parser.ParseException: Unexpected token + at position 168.
Could not find a valid solution so dropping question here.
I think you need to read and understand the docs, that's not how you set request headers. Here's what I think you were trying to do, and I hope that this helps others who try to use this "Restful Booker" application.
Feature:
Scenario:
* url 'https://restful-booker.herokuapp.com'
* path 'auth'
* request { username: 'admin', password: 'password123' }
* method post
* status 200
* def token = response.token
* header Accept = 'application/json'
* path 'booking'
* request
"""
{
"firstname" : "Jim",
"lastname" : "Brown",
"totalprice" : 111,
"depositpaid" : true,
"bookingdates" : {
"checkin" : "2018-01-01",
"checkout" : "2019-01-01"
},
"additionalneeds" : "Breakfast"
}
"""
* method post
* status 200
* path 'booking', response.bookingid
* cookie token = token
* method delete
* status 201