1

I am trying to send an iCalendar to webpage but when I send it there is no line separation and it is not considered as correct iCalendar format. If I send iCalendar format its just JSON format. And if its calendar.toString() there is no line separation. How can I send it in correct format?

Calendar calendar = iCalendarService.getCalendar();
System.out.println(calendar); //Correct format in console
return ResponseEntity.ok(calendar.toString()); //No line separation
//return ResponseEntity.ok(calendar); // Json
Matthijs
  • 2,483
  • 5
  • 22
  • 33
cuteBrick
  • 75
  • 2
  • 8

1 Answers1

0

If your code is defined at a Controller method level, try to set the media type to text/calendar:

@RequestMapping(
    method = RequestMethod.GET,
    value = "/your/path",
    produces = "text/calendar"
)

Alternatively, you can try the following return line:

return ResponseEntity.ok().contentType(new MediaType("text", "calendar")).body(calendar.toString());
Soufiane Sakhi
  • 809
  • 10
  • 13