Hi!
I'm just getting started with the Community REST API calls, and trying to write a basic Powershell script that uses an API key for authentications. The user I used to generate the key is an admin with the correct API permissions, but I'm getting a 403 every time. Does anyone know what I'm doing wrong here?
# Define the API endpoint, API key, and username
$apiUrl = "https://xxxxxxxxxxxxx.com/api.ashx/v2/info.json"
$apiKey = "********************************************"
$username = "test@test.com"
# Create the base64-encoded user token
$userToken = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("${apiKey}:${username}"))
# Create the web request
$request = [System.Net.WebRequest]::Create($apiUrl)
$request.Method = "GET"
# Add the authentication header
$request.Headers.Add("Rest-User-Token", $userToken)
# Get the response
$response = $request.GetResponse()
# Output the response
$responseStream = $response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($responseStream)
$responseBody = $reader.ReadToEnd()
$reader.Close()
$responseStream.Close()
write-output $responseBody