Getting issue during running a api command

Ok , fixing the cluster status would be the first step.

Check the cluster status and try to make it green first.
you can use these commands to get an idea of what's going in the cluster.

curl -XGET "http://localhost:9200/_cluster/stats"
curl -XGET "http://localhost:9200/_cat/shards"
curl -XGET "http://localhost:9200/_nodes/hot_threads"
curl -XGET "http://localhost:9200/_cat/nodes"
curl -XGET "http://localhost:9200/_cluster/health"

please read the below post to know more about this issue:

And this page to diagnose further:
: Fix common cluster issues | Elasticsearch Guide [7.14] | Elastic