Error:invalid_client getting the Client Credentials

Thank you very much @FoxHere for the response.
I have tried similar way with some JS code and it worked. Posting the JS version that worked , in case anyone else is looking for.

var xhttp = new XMLHttpRequest();

var data = "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&scope=OR.Robots+OR.Robots.Read+OR.Robots.Write+OR.Machines+OR.Machines.Read+OR.Machines.Write+OR.Execution+OR.Execution.Read+OR.Execution.Write+OR.Assets+OR.Jobs.Write+OR.Jobs+OR.Jobs.Read";

var res = {};
xhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
      console.log(JSON.parse(this.responseText));
    res = JSON.parse(this.responseText);
  }

};
xhttp.open("POST","https://cloud.uipath.com/identity_/connect/token", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xhttp.send(data);

However the problems are not stopping there. The next calls to Get Releases, Start Job using Authorization header with Bearer token coming from above call’s response, are also failing.
I am not sure why, but the I am continuously getting a 405 error reponse. Following is the JS code I tried for Get Releases
var xhttp1 = new XMLHttpRequest();

xhttp1.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    console.log(JSON.parse(this.responseText));
  }
};
xhttp1.open("GET","https://cloud.uipath.com/invenivcsltd/DefaultTenant/odata/Releases?$filter=Name eq 'RELEASE_NAME'", false);
//xhttp.setRequestHeader("Content-type", "application/json; odata.metadata=minimal; odata.streaming=true");
//xhttp1.setRequestHeader("Access-Control-Allow-Origin", "*");
xhttp1.setRequestHeader("Authorization", "Bearer "+res.access_token);
xhttp1.setRequestHeader("X-UIPATH-OrganizationUnitId", "1340217");
//xhttp1.setRequestHeader("X-UIPATH-TenantName", "DefaultTenant");
xhttp1.send();

I tried checking all the details and everything seems fine. But following is the response I am receiving.


Documentation says to use GET Method. But it is giving 405 Method not allowed error on pre-flight and COR on original call.
Kindly point my mistake.