I am an admin on an organisation account and I have created a Token using the My Account>Security menu options.
I have then fed that Token into the below simple powershell script (I have removed the actual values used):
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$apiUser = “REDACTED”
$apiUserPassword = “REDACTED”
#Create our credentials object
$pwd = ConvertTo-SecureString $apiUserPassword -AsPlainText -Force;
$Cred = New-Object System.Management.Automation.PSCredential ($apiUser, $pwd);
$response = Invoke-WebRequest -Uri $URL -Credential $Cred -Method POST
The response I get is follows:
Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.
I have attempted this in Postman too using Http Basic Authentication and I get the same result.
Can any advise what I am doing wrong?