2017-04-10 63 views
1

我是Restassured Webservice自動化的新手。 我可以獲取OAuth2令牌並將其保存爲字符串。但是當我在Authorization頭中傳遞這個字符串時,我得到了403錯誤。有人可以幫助我工作代碼Restassured後請求與授權標頭

工作代碼標記存儲在一個字符串:

​​

代碼工作不低於:

`given().header("Authorization", pswd) 
    .body(content).with().contentType("application/json") 
    .when() 
    .post("/api/path") 
    .then().statusCode(200);` 

我得到403錯誤。

回答

1

你可以試試下面的

`given().auth().oauth2(accessToken). 
    .body(content).with().contentType("application/json") 
    .when() 
    .post("/api/path") 
    .then().statusCode(200)` 
相關問題