My Post method in Angular
private attachAuthorization(): RequestOptions {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('HttpHeaders.ACCEPT', 'MediaType.APPLICATION_JSON_VALUE');
headers.append('Content-Type', 'charset=UTF-8');
headers.append ('Authorization',sessionStorage.getItem('token'));
//console.log(localStorage.getItem('token'));
const options = new RequestOptions({
headers: headers,
responseType: ResponseContentType.Json,
});
return options;}
public post(url: string, requestData: any):any {
const options = this.attachAuthorization();
return this.http.post(url, JSON.stringify(requestData),options);
}
Json Array
[{"columnname":"symbol","filterby":"","values":"","time":"","datatype":"String"},{"columnname":"order_Receiving_Date","filterby":"","values":"","time":"","datatype":"DateRange"},{"columnname":"event_Type","filterby":"","values":"","time":"","datatype":"String"},{"columnname":"firm_ROE_ID","filterby":"","values":"","time":"","datatype":"int"},{"columnname":"rejected_ROE_ID","filterby":"","values":"","time":"","datatype":"int"}]
API Method
@RequestMapping(value = {"/Oats-Exception-summary"}, method = RequestMethod.POST)
public ResponseEntity<List<OatsExceptionSummary>> OatsExceptionSummaryPost(
@RequestBody JSONArray payload)throws SQLException,JSONException,Exception {
System.out.println(payload);
String FilterData="";
/*JSONObject jsonObj=new JSONObject(payload);*/
List<OatsExceptionSummary> Data =ISurveillanceService.getOatsExecptionSummary(FilterData);
if (Data.isEmpty()) {
return new ResponseEntity<List<OatsExceptionSummary>>(HttpStatus.NO_CONTENT);
} else {
return new ResponseEntity<List<OatsExceptionSummary>>(Data, HttpStatus.OK);
}
}
**Error in API **
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity> com.zcon.RSMS.SpringBoot_RSMS2.controller.SurveillanceController.OatsExceptionSummaryPost(org.json.JSONArray) throws java.sql.SQLException,org.json.JSONException,java.lang.Exception 2018-05-22 12:56:09.624 WARN 11855 --- [nio-8090-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public org.springframework.http.ResponseEntity> com.zcon.RSMS.SpringBoot_RSMS2.controller.SurveillanceController.OatsExceptionSummaryPost(org.json.JSONArray) throws java.sql.SQLException,org.json.JSONException,java.lang.Exception
System.out.println(payload);?