会尽量精确地提出问题。对不起,如果做不到的话!
分配了一个任务,以便从下面的给定链接中自动执行api。
https://restful-booker.herokuapp.com/apidoc/index.html
通过使用Api链,我应该首先从"Create“api中生成令牌,并将其传递到头中进行授权,从而实现”更新预订“api的自动化。我在邮递员那里检查过它在空手道上工作很好我写了这段代码
* 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 }变量auth_token从第一个api响应中获取令牌,在相同的情况下,我试图使用上面的头运行update,但是它一直给出这个错误。
net.minidev.json.parser.ParseException: Unexpected token + at position 168.在这里找不到有效的解决方案。
发布于 2022-05-19 04:30:17
我认为您需要阅读和理解文档,而不是这样设置请求头。这里是我认为你想要做的事情,我希望这能帮助那些尝试使用这个"Restful“应用程序的人。
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 201https://stackoverflow.com/questions/72295097
复制相似问题