将api密钥设置为可靠的测试

时间:2017-01-26 08:42:30

标签: rest-assured

我正在尝试通过api密钥进行放心。从邮递员那里,我使用'X-Api-Key'获得了有价值的repsonse数据。但请放心,我看到空指针异常

Response res = given()      
        .header("key","55af7bc105c9c2ee98e2abb32979fee")
        .when()
    .get ("https://mbaseurl/api/v1/search-listings/").then().
 //   contentType(ContentType.JSON).  // check that the content type return from the API is JSON
    extract().response();

我尝试使用.header(“X-Api-Key”,“value”)传递键值但是没有成功

1 个答案:

答案 0 :(得分:0)

Map<String, String> pMap = new HashMap<String, String>();
        pMap.put("apiKey","yourAPIKEY");
        pMap.put("format","json");
        pMap.put("show","storeId,`storeType`,name,city,region");