Last active
August 2, 2016 12:21
-
-
Save petrsvihlik/204515a87a14217bd3c2a2b991814d40 to your computer and use it in GitHub Desktop.
Using Kentico REST API in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "http://localhost/kentico/rest/CMS.User/administrator" | |
# Enter correct username:password | |
$credentialsBytes = [System.Text.Encoding]::UTF8.GetBytes("administrator:") | |
$credentialsEncoded = [System.Convert]::ToBase64String($credentialsBytes) | |
$headers = @{} | |
$headers.Add("Authorization", "Basic $($credentialsEncoded)") | |
# Change requested mime/type | |
#$headers.Add("Content-Type", "application/json") | |
# Add -OutFile c:\file.xml if you want to save the output to a file | |
$xml = (Invoke-RestMethod -Uri $url -Method "Get" -Headers $headers) | |
# Print user | |
#$xml.SelectNodes('//CMS_User') | |
# Update user | |
$xml.data.CMS_User.UserNickName = "Jack" | |
# Update user using PUT method | |
$result = (Invoke-RestMethod -Uri $url -Method "Put" -Headers $headers -Body $xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment