Security Controls REST API

Home 

Exercise 1 - Create a Credential

Goal

Create a credential that can be used to access all of the machines in your domain. For example, you might create the credential using the user name and password pair that applies to a service account within the domain.

Try it yourself

Create a credential named Sample Credential by submitting a POST request similar to the following:

Change the userName and password values as needed.

Postman example

https://localhost:3121/st/console/api/v1.0/credentials
			{
			"name":"Sample Credential",
			"userName":"Admin",
			"password":{"ClearText":"SamplePW"}
		}

 

PowerShell script example

$credentialUrl = "https://localhost:3121/st/console/api/v1.0/credentials"
			$credential = Get-Credential
			$credentialBody = @{
			name = "Sample Credential" ;
			password = @{ClearText = "SamplePW" };
			username = "Admin"
			} | ConvertTo-Json -Depth 99
		Invoke-RestMethod -Method Post -Credential $credential -URI $credentialUrl -Body $credentialBody -ContentType "application/json" | ConvertTo-Json -Depth 99

For information on creating a credential using a secure password rather than a clear text password, see function Add-Credential in the Start-to-Finish Example.

Output

The result is a JSON-formatted response similar to the following:

{
        "id": "ce45a98c-e8f0-4f88-a972-d66f99a9ef03",
        "links": {
        "self": {
        "href": "https://device-name.fakedomain.com:3121/st/console/api/v1.0/credentials/ce45a98c-e8f0-4f88-a972-d66f99a9ef03"
        }
        },
        "name": "Sample Credential",
        "userName": "Admin"
        }

 

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other