Unable to Get API token

Hi all,

Need help !! This is my first post.

i am trying to get API token/Key to read some logs from Kibana server using API.
Below is the information i Have used.

API URI - http://xxxxxxxxxxxxxxxx:9200/_xpack/security/oauth2/token
Body - {
"grant_type": "password",
"username" : "username",
"password" : "password"

}

but getting below error
'{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "missing authentication token for REST request [/_xpack/security/oauth2/token]",
"header": {
"WWW-Authenticate": "Basic realm="security" charset="UTF-8""
}
}
],
"type": "security_exception",
"reason": "missing authentication token for REST request [/_xpack/security/oauth2/token]",
"header": {
"WWW-Authenticate": "Basic realm="security" charset="UTF-8""
}
},
"status": 401
}'

Please assist.