Creating template : Validation Failed: 1: template is missing;

What version of Es are you using? I assume you use before 6.0.
There is changes in 6.0.
https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal

BTW, please format your code using </> icon as explained in this guide and not the citation button. It will make your post more readable.