我正在打印一个类的字段。课程如下:
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);
}
}
在 Postman 中运行api时,出现以下错误:
{
"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"
}
控制器方法
@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);
}
请建议如何解决此错误。
暂无答案!
目前还没有任何答案,快来回答吧!