嗨,我正在尝试向 Java 中的改造调用添加不记名令牌,但我似乎无法通过它。
目前我使用一种方法登录,这会创建一个不记名令牌,我试图将令牌添加到 Get Call,但它只是返回 401 错误,我是否正确地将令牌添加到调用中?
@GET("diagnosis/configuration")
Call<ResponseBody> getFavourites (@Query("favourite") Boolean fave,@Header("Bearer Token") String authHeader);
@POST("auth/login")
Call<LoginResponse> postLogin (@Body LoginCredentialsBody body);
public class LoginApiStepDefinition extends TestBaseFix {
Retrofit retrofit = super.buildRetrofit(super.buildOkHttpClient());
RetrofitCallsLogin call = retrofit.create(RetrofitCallsLogin.class);
RetrofitCallsGetFavourites favecall = retrofit.create(RetrofitCallsGetFavourites.class);
private Response<LoginResponse> responseBody;
private String favouritesResponseBody;
String usernameValue;
String passwordValue;
@And("I login with {string} and {string} to return login token")
public void iLoginWithAndToReturnLoginToken(String username, String password) throws Exception {
LoginApi(username, password);
}
public String LoginApi(String username, String password) throws …Run Code Online (Sandbox Code Playgroud) 我试图从我的页面源获取一些信息.我在每个版本上运行自动化测试,但希望避免手动更新版本号,因为我试图在CI中集成我的测试,并希望我可以从页面源中提取标签.
所有我知道这里的工作是Drivers.getDriver.getPageSource但不知道如何提取信息.
我遇到的主要问题是版本分为两部分:
<meta http-equiv ="version"content ="1.4.39">
我希望能够从页面源中获取1.4.39并添加到字符串
我正在使用Katalon Studio并使用它来发送API请求.该请求基本上是返回我想在HTTP标头中使用的信息.我可以使用Groovy或Java来提取这个,但不知道我该怎么做.
我试过create_game_response.getHeadewrFields(GameCode)以获得GameCode,但它无法正常工作.
这是我使用的代码
WS.sendRequest(findTestObject('UserRestService/Create Game'))
WS.verifyResponseStatusCode(create_game_response, 201)
def header_text = create_game_response.getHeaderFields()
println(header_text)
def game_code = create_game_response.getHeaderFields();
String game_code_list = game_code.toString()
println(game_code_list)
Run Code Online (Sandbox Code Playgroud)
这是回应:
{GameCode=[1jwoz2qy0js], Transfer-Encoding=[chunked], null=[HTTP/1.1 201 Created]}
Run Code Online (Sandbox Code Playgroud)
我试图从游戏代码中提取"1jwoz2qy0js"并将其用作字符串,我该怎么做?