我在java代码中面临一些问题:
package com.automation.com.automation.<name>;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.junit.Test;
import static com.jayway.restassured.RestAssured.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
public class SendDCandidateDate {
@Test
public void sendCandidateData() throws FileNotFoundException {
String accessToken = "<your access token comes here>";
String apiUrl = "<your API url comes here>";
JSONParser parser = new JSONParser();
try {
Object object = parser.parse(new FileReader("src/main/resources/Full_List.json"));
JSONObject jsonObject = (JSONObject) object;
given().auth().preemptive().oauth2(accessToken);
given().body(jsonObject).when().post(apiUrl).then().assertThat().statusCode(200);
}catch (Exception ex) {
System.out.println(ex);
}
}
}
我没有例外,但是断言返回错误404而不是200.(错误401现在也可以接受,这意味着accessToken已过期,它也是预期的行为)。
我认为我的代码中存在逻辑问题,任何人都可以帮助我吗?