Translate curl to Powershell Invoke-Restmethod

I'm having issues converting a curl command into Powershell Invoke-RestMethod. Ihave tried a number of different ways but i get error message: Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

The curl command that i need to convert for powershell:

curl -k -d "grant_type=client_credentials" -H "Authorization: Basic sometoken1234567890"

What i have tried so far:

$token = "c0a6dcae-e14b-3255-88a9-c83df513b314"
$headers = @{Authorization = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("sometoken1234567890"))}
$body = ConvertTo-Json @{"grant_type" = "client_credentials"}

Invoke-RestMethod -Method Post -Headers $headers -Body $body -Uri ""


$body = @{
grant_type = "client_credentials"

$headers = @{
Authorization = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("sometoken1234567890"))
Accept = "application/json"
ContentType = "application/json"

$params = @{
Method = "Post"
Uri = ""
Body = $body

Header = $headers

Invoke-RestMethod @params

I get the same error for both of them

I would be very much appreciated if someone could help


Thanks to Daniel Stenberg i managed to get it working by running the below code:

$curl = curl.exe -k -d "grant_type=client_credentials" -H "Authorization: Basic sometoken1234567890" | ConvertFrom-Json 


Previous : How do I pull last 3 levels from a file path in python?
Next : Interpolate row-wise values of 0 between two columns with values >0 in R