I am trying to print the fields of a class. The class is as follows:
package com.telstra.sdwan.portal.model.neo4j;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import java.util.HashMap;
@NodeEntity
@Getter
@Setter
@NoArgsConstructor
public class Metrics {
@Id
@GeneratedValue
public Long id;
public String name;
public HashMap<String, Long> success = new HashMap<String, Long>();
public HashMap<String, Long> failure = new HashMap<String, Long>();
public Metrics(String name) {
this.name = name;
success.put(name, 0L);
failure.put(name, 0L);
}
}
On running the API in the postman I am getting this error:
{
"timestamp": "2021-01-27T16:28:44.5161857",
"status": "BAD_REQUEST",
"errors": [
"Malformed JSON request"
],
"message": "Required request body is missing: public org.springframework.http.ResponseEntity<com.telstra.sdwan.portal.model.neo4j.Metrics> com.telstra.sdwan.portal.controller.ConfigOpsAppController.apiCalled(com.telstra.sdwan.portal.model.neo4j.Metrics)",
"data": [],
"path": "/api/configops-app/metrics"
}
The Controller Method
@ApiOperation("Count of the number of times an API is called")
@GetMapping(value="/metrics")
@PreAuthorize("hasRole('User')")
public ResponseEntity<Metrics> apiCalled(@RequestBody Metrics metrics){
return configOpsAPIService.apiCount(metrics);
}
Please suggest how this error can be resolved.
question from:
https://stackoverflow.com/questions/65918002/org-springframework-http-converter-httpmessagenotreadableexception-when-sending 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…