Application Integration
1752577 Members
5596 Online
108788 Solutions
New Discussion

Cannoit change Encryption Passphrase through REST API

 
yolinares
New Member

Cannoit change Encryption Passphrase through REST API

When I attempt to change my Encryption Passphrase through the rest API I keep getting "The remote server returned an error: (401) Unauthorized." Below is the commands im running to attempt to update the passphrase. If I am reading/understanding the REST API documentation (https://infosight.hpe.com/InfoSight/media/cms/active/public/pubs_REST_API_Reference_NOS_51x.whz/qyk1480349012860.html)  all I need to submit to update the passphrase is the ID of the master key, the current passphrase and the new passphrase.  Any help would be appericated.

 

# Get the Token to connect to the Nimble
$data = @{
username = $username
password = $password
}
$body = convertto-json (@{ data = $data })

$uri = "https://" + $nimblearray + ":5392/v1/tokens"
$nimbleToken = try {
Invoke-RestMethod -Uri $uri -Method Post -Body $body
}
catch
{
throw "Nimble - Couldn't connect to $nimblearray"
}

if ($nimbleToken -ne $null)
{
$token = $nimbleToken.data.session_token
}


# Get the information about the user you need to change
$header = @{"X-Auth-Token" = $token}
$uri = "https://" + $nimblearray + ":5392/v1/master_key"
$keyList = Invoke-RestMethod -Uri $uri -Method Get -Header $header

$data = @{
id = $keyList.data.id
passphrase = $passphrase
new_passphrase = $new_passphrase
}

$body = convertto-json (@{ data = $data })

$uri = "https://" + $nimblearray + ":5392/v1/master_key/" + $keyList.data.id
Invoke-RestMethod -Uri $uri -Method Put -Body $body -Headers $header

1 REPLY 1
yolinares
New Member

Re: Cannoit change Encryption Passphrase through REST API

well my issue was with special characters and storing the intial passphrase in a double quotes string vs a single quotes string in my testing. my commands below worked once i fixed the special characters.