Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Requests for TestTrail



I am trying to receive “id” for my milestone in Test Trial

I am doing request:

public String getMilestoneID(String milestoneID) throws Exception {
    String new_milestone_ID  = new URIBuilder()
            .setHost(HOST + "/" + Requests.isMilestoneID + "/" + milestoneID)
    String ID = parsingJSON(TestHTTPUtils.executeGetRequest(String.valueOf(new_milestone_ID)));
    return ID;

My request:

public static String parsingJSON(byte[] json) throws ParseException {
String input = new String(json);
JsonParser parser = new JsonParser();
JsonObject mainObject = (JsonObject) parser.parse(input);
JsonObject pItem = (JsonObject) mainObject.get(“id”);
return pItem.get(“id”).toString();

And for input - i have: {“error”:“Content-Type header missing (use Content-Type: application/json)”}

Could you help me, please


Hey, did you manage to solve this problem?


It looks like the OP did not have the Header Type defined in the call “Content-Type header missing” and it tell them to use the following Content Type " Content-Type: application/json" for the header.


True, but if you’re relying on testrail’s api then you don’t get to specify any of it. Here’s how I did it just now.

  1. Create Milestone class (im using lombok):

     public class Milestone {
        	private int id;
        	private String name;
        	private String description;
        	private int projectId;
        	private Date dueOn;
        	private Boolean isCompleted;
        	private Date completedOn;
        	private String url;
  2. Now the method:

pubilc void getMilestoneId() throws IOException, APIException {
JSONArray response = (JSONArray) client.sendGet(“get_milestones/2”); -> {
try {
return mapper.readValue(x.toString(), Milestone.class);
} catch (IOException e) {
return Milestone.builder().build();
}).map(x -> ((Milestone) x).getId()).forEach(System.err::println);
System.out.println("BEHOLD ZIE ID: " + response);

Please note: this is a quick solution, I’m still trying to figure out a proper way of doing it myself. but the one above works. Hope it will help you and others. If you get better ideas, please share :slight_smile: