Fisheye/Crucible REST API giving 401 error while adding git repository

Hi Team,

I am trying to add git repository using Fisheye/Crucible REST API. I tried providing username and passowrd with basic authentication and also tried with bearer token. But in both ways, it is giving 401 (client must be authenticated to access resource) error. I am using powershell script to call REST API. Below is my code:

function New-FisheyeRepo {
<#
.SYNOPSIS
Used add a new AWS CodeCommit repo to Fisheye.
.DESCRIPTION
Used add a new AWS CodeCommit repo to Fisheye.
.NOTES
DK 5/30/2018
#>
[CmdletBinding()]
param(
[parameter(Mandatory=$True,ValueFromPipeline=$True)][string] $branchname,
[parameter(Mandatory=$True,ValueFromPipeline=$True)][string] $fisheyehost,
[parameter(Mandatory=$False,ValueFromPipeline=$True)][string] $URI=“https://fisheye.4yoursoul.net/rest/api/1.0/rest-service-fecru/admin/repositories
)

$CCRepoToAdd = "https://git-codecommit.us-west-2.amazonaws.com/v1/repos/asi"


$result=""
$authobject= New-Object PSObject -Property @{
    username = $(Convert-FromBase64("YnVpbGQ="))
    password= $(Convert-FromBase64("QnUxbGRlcjI="))
}

#$basicAuth= ("Basic " + [string](Convert-ToBase64("YnVpbGQ=" + ":" + "QnUxbGRlcjI=")))
$tokenAuth = "Bearer 352c5b6a5bc9b3680ade28374d40ed6c61adf7f2"
$headers = @{
        "Authorization" = $tokenAuth
        "Content-Type"="application/json"
    }

$postbody = New-object PSObject -Property @{
      type = "git"
      name = "asi"
      url = $CCRepoToAdd
      username = "devops-at-172601357080"
      password = "E3qKv5vBSU1CWaUsScJ8yXN2skzvJesQT9RPuzwoJn4="
      branches = {
          name = $branchname
      }
  
}

$jsonpostbody=ConvertTo-Json $postbody

write-debug "Sending creation request $jsonpostbody to $URI"

#$result= Invoke-JIRARequest -URI $URI -method POST -body $jsonpostbody
$result = @(Invoke-RestMethod -Uri $URI -Method POST -Headers $headers -Body $jsonpostbody -ErrorVariable RestError -ErrorAction SilentlyContinue)

#return result
$result

if ($result.name) {
    $repoURI=$repoURI.replace("{repository}","$branchname")
    $startresult= Invoke-JIRARequest -URI $repoURI -method PUT
    if ($startresult) {
        write-verbose "Repo $branchname started (call was to $repoURI)"
    }
}

Any help in resolving this error would be of great help

}