Wednesday, August 17, 2022

Spring Boot : how to fix Unsupported file format in sitemap creation

  

If you ever faced this issue in the dynamic sitemap generated?

The error says Incorrect http header content-type: "application/json;charset=UTF-8" (expected: "application/xml")

This issue was caused by not setting the header content type properly. By default HTML page will return the text/html content type. 

In my case it was 


you can verify this network tab in chrome and firefox,




resolution:

You need to specify the application/xml content type in the request header as below,

@RequestMapping(value = "/sitemap.xml",method = RequestMethod.GET,
produces = MediaType.APPLICATION_XML_VALUE)
Then it should work properly. Verify it in chrome or firefox before submitting it to google again.

This worked :)



No comments:

Post a Comment