解析对自定义 POJO 的响应 header

Resolve response header to a custom POJO

打电话给 API

我现在创建了一个 POJO 来映射 Json 响应

@JsonInclude(JsonInclude.Include.NON_NULL)
JsonIgnoreProperties(ignoreUnknown = true)
public  class ResponseBricks<T>{

public ResponseBricks<T>(@JsonProperty("location") Location location,
        @JsonProperty("properties") Properties properties, 
         @JsonProperty("error") AzureError error) {

    this.location = location;
    this.properties = properties;
    this.error = error;
}

public Location getLocation() {
    return location;
}

public void setLocation(Location  location) {
    this.location = location;
}

public T getProperties() {
    return properties;
}

public void setProperties(T properties) {
    this.properties = properties;
}

public AzureError getError() {
    return error;
}

public void setErrorAzureError error) {
    this.error = error;
}

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}



public Response getResponse() {
    return response;
}

public void setResponse(Response response) {
    this.response = response;
}



private Location location;
private T properties;
private String id;
private String name;
private AzureError error;
private Response response;

}

现在我需要 Headers 的响应,因此包含

private Response response;

但是,响应并未准确映射到来自 Azure 调用的响应,并且响应为空。 我可以获得 headers 如果我将响应保留为 Response 而不是我的自定义 POJO.However 有什么方法可以使用自定义 pojo 并将响应作为其中的变量?

所以尝试了这个 out.The 唯一的方法是使用 Response.Custom Pojo 的响应不会给出 headers。 Response 有很多方法,不仅可以获取 headers,还可以获取 body.