2016-03-29 8 views
0

REST保証付きのRESTポストURLを実行できません。ステータス404エラーが表示されます。私たちのRESTのURLは、認証、ボディなどを必要としません。同じURLがPOSTMAN、RESTEasyでうまくいきます。私はあなたがあなたの答えに説明を含めた場合の答えは良く受け入れ、理解するのが容易である通常応答にRESTを実行することができませんリクエスト - REST保証済み

@Test 
public void httpPost() throws JSONException,InterruptedException { 
//Initializing Rest API's URL 
String APIUrl = "http://xyz:8080/jbpm-console/rest/runtime/317002:31702Project:0.0.5-SNAPSHOT/process/317002Project.ScriptTask/start?superUser=cw-user"; 
RequestSpecBuilder builder = new RequestSpecBuilder(); 
builder.setContentType("application/json;charset=UTF-8"); 
RequestSpecification requestSpec = builder.build(); 

//Response response = given().spec(requestSpec).when().post(APIUrl); 
//Response response= given().contentType("application/json").when().post(APIUrl); 
Response response = given().authentication().preemptive().basic("", "").spec(requestSpec).when().post(APIUrl); 
//Response response= expect().contentType("application/json;charset=UTF-8").statusCode(200).when().post(APIUrl); 

JSONObject JSONResponseBody = new JSONObject(response.body().asString()); 
System.out.println(JSONResponseBody); 
} 

答えて

0
URL file = Resources.getResource("ModyNewFieldsReq.json"); 

String myRequest = Resources.toString(file,Charsets.UTF_8); 

     Response fieldResponse = given() 
      .header("Authorization", AuthrztionValue) 
      .header("X-App-Client-Id", XappClintIDvalue) 
      .contentType("application/vnd.api+json") 
      .body(myRequest).with() 

     .when() 
      .post(dataPostUrl)  

     .then() 
      .assertThat() 
      .log().ifError() 
      .statusCode(200) 
      .extract().response(); 

     Assert.assertFalse(fieldResponse.asString().contains("isError")); 
+0

を取得するための4つのすべての組み合わせを試してみました。ありがとう! – JoelC

関連する問題