I want to call java Api from my angular 2 app.I used typescript Map to send request in java app.
My RestEndpoint in java is like this:
@PostMapping(value = Constants.PATH_BASE + "/sync/list")
public ResponseEntity<?>configureQueueList(@RequestBody Map<String,Integer> map){
//code here
}
I got this error when i try to use typescript map:
JSON parse error: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token\n at [Source: java.io.PushbackInputStream@f6b068c; line: 1, column: 1]
In postman i use this as raw body and it works
{ "key1":"value1", "key2":"value2", ..... ..... }
Edit 2: Type Script Endpoint
postMap(value:Map<string,number>){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.url, value, options)
.map(success => success.status)
.catch(this.handleError);
}