I'm following this IBM cloud doc to generate a IAM token to work with the specific account to which i have access with account id doc
The API for generating an IAM token is documented here in the IAM Identity Services API. You are using different (and unsupported) header and body parameters. This could cause the error.
The header should only be 'Content-Type: application/x-www-form-urlencoded'
. The body should include the grant type and the API key.