InControl 2 API ouath2 token with M code fails

Working with PowerBI to create some charts from IC2 data in different format to that in IC2 for a customer.
Trying to get oauth2 token details in IC2 using m code as below but no matter what I do I only get back 400 bad request. I know the client_id, client_secret are OK as I can run curl OK and construct a POST command that runs as expected from Fiddler OK.
I think my issue is that the POST statement that gets sent is not appending the postdata correctly to the call. Any ideas welcome.
Thank you.

GetAPIToken = ( client_id, client_secret as text) =>

postdata = “client_id=” & client_id & “&client_secret=” & client_secret & “&grant_type=client_credentials”,
URL = “”,
DataQuery= Web.Contents( URL, [Headers = [#“ContentType” = “application/x-www-form-urlencoded”], #“Content” = Text.ToBinary(postdata)]),
DataOut = Json.Document(DataQuery),
source = DataOut

Please check if your request is sending the correct data.
If the data has any missing fields “client_id”, “client_secret”, “grant_type”, it would return 400 request.
You may try check the error response from Fiddler to see which field is missing.

Error response sample:
response code: 400
response data: {“error_description”: “Missing grant_type parameter value”, “error”: “invalid_request”}