[Consul-Template] Error registering service : Unexpected response code: 400 (Invalid check: TTL must be > 0 for TTL checks)

I want to register my services with multiple script checks for each. I store the values in consul kv and call them with consul-template to write a JSON file as the configuration file to register services with cli “consul services register configuration.json”.
However, when I register services with the configuration file, I always encounter the same error which says “Error registering service : Unexpected response code: 400 (Invalid check: TTL must be > 0 for TTL checks)”. Consul seems to recognize the checks as TTL checks which they are not.
I turn to use consul API “/agent/service/register” to register my services, but it only can register one service each time. Is there any API that can register multiple services simultaneously with one request?
Here’s my configuration.json

{
    "service": 
        {
            "ID": "Ambrose",
            "Name": "check",
            "Meta": {
                "redis_version": "4.0"
            },
            "Address": "ip",
            "Port": 8500,
            "Checks": [
                {
                    "Name": "Ping",
                    "args": [
                        "ping",
                        "-c1",
                        "ip"
                    ],
                    "Timeout": "5s",
                    "Interval": "30s"
                },
                {
                    "Name": "Root Login",
                    "args": [
                        "/usr/bin/python3",
                        "/consul/data/data/python/root.py",
                        "ip"
                    ],
                    "Timeout": "20s",
                    "Interval": "50s"
                },
                {
                    "Name": "User Login",
                    "args": [
                        "/usr/bin/python3",
                        "/consul/data/data/python/user.py",
                        "ip"
                    ],
                    "Timeout": "20s",
                    "Interval": "50s"
                }
            ]
        }
}

root.py

import paramiko, sys

def ssh(hostname, port=22):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        result = ssh.connect(hostname=hostname, port=port, username="username", password="password")
        if result is None:
            print("Access Success!")
            sys.exit(2)
        else:
            sys.exit(2)
    except paramiko.AuthenticationException as e:
        print(e)
        sys.exit(0)
    except Exception as e:
        print(e)
        sys.exit(2)

try:
    host = sys.argv[1]
    ssh(host)
except Exception as e:
    print(sys.argv)
    print(e)
    sys.exit(2)

user.py

import paramiko, sys

def ssh(hostname, port=22):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        result = ssh.connect(hostname=hostname, port=port, username="username", password="password")
        if result is None:
            print("Access Success!")
            sys.exit(0)
        else:
            sys.exit(2)
    except Exception as e:
        print(e)
        sys.exit(2)

try:
    host = sys.argv[1]
    ssh(host)
except Exception as e:
    print(sys.argv)
    print(e)
    sys.exit(2)

The first check is to ping a VM server. The second and third one is to use python with paramiko to ssh into the server to see if the root and user can get in.

I also have another configuration file named “rkm.json” to register services with HTTP checks that work totally fine with cli registration command. The only difference between the two files is the check method.

rkm.json

{
    "services": [
        {
            "ID": "RKM",
            "Name": "check",
            "Meta": {
                "redis_version": "4.0"
            },
            "Address": "ip",
            "Port": 8500,
            "Checks": [
                {
                    "Name": "UI",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9882/",
                    "Method": "GET",
                    "Timeout": "5s",
                    "Interval": "30s"
                },
                {
                    "Name": "Login",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9894/api/v1/account/auth",
                    "Method": "POST",
                    "Header": { "Content-Type": ["application/json"] },
                    "Body": "{ \"password\": \"password\", \"username\": \"username\" }",
                    "Timeout": "5s",
                    "Interval": "30s"
                },
                {
                    "Name": "List Server",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9894/api/v1/server",
                    "Method": "GET",
                    "Timeout": "5s",
                    "Interval": "30s"
                }
            ]
        },
        {
            "ID": "RKM2",
            "Name": "check",
            "Meta": {
                "redis_version": "4.0"
            },
            "Address": "ip",
            "Port": 8500,
            "Checks": [
                {
                    "Name": "UI",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9882/",
                    "Method": "GET",
                    "Timeout": "5s",
                    "Interval": "30s"
                },
                {
                    "Name": "Login",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9894/api/v1/account/auth",
                    "Method": "POST",
                    "Header": { "Content-Type": ["application/json"] },
                    "Body": "{ \"password\": \"password\", \"username\": \"username\" }",
                    "Timeout": "5s",
                    "Interval": "30s"
                },
                {
                    "Name": "List Server",
                    "DeregisterCriticalServiceAfter": "3000h",
                    "Http": "http://ip:9894/api/v1/server",
                    "Method": "GET",
                    "Timeout": "5s",
                    "Interval": "30s"
                }
            ]
        }
    ]
}```
I have a workaround, for now, to register with curl one by one JSON file, and I need to write as many files as the number of services. Yet I’m supposed to register all services with only one cli command to fulfill what I expected. If anyone could help me with this problem, I would be so thankful for your help.