Colin,
Thanks for the pointers. The code listing in the other article is a bit dated. For instance, the UseBasicParsing
parameter is now deprecated.
Here is a code listing that I got to work:
# already verified preconditions:
# the routine to retrieve an $accessToken works and supplies a valid token consistently
# $tenant and $importFileName have valid values
# file referenced by $importFileName contains valid JSON for a Source object
[Hashtable]$bulkFileContents = @{
tenant = $tenant
version = 1
timestamp = Get-Date -Format "o"
options = @{
includeTypes = @("SOURCE")
objectOptions = $null
}
objects = @(
@{
version = 1
self = @{
type = "SOURCE"
name = "AD - Contoso"
}
object = Get-Content -Path $importFileName -Raw | ConvertFrom-Json -AsHashtable
}
)
}
[FileInfo]$tempFile = New-TemporaryFile
Set-Content -Path $tempFile -Value ($bulkFileContents | ConvertTo-Json -Depth 100)
[Hashtable]$formContents = @{
data = $tempFile
}
[Hashtable]$requestParameters = @{
Method = [WebRequestMethod]::Post
Uri = "https://$tenant.api.identitynow.com/beta/sp-config/import"
Authentication = [WebAuthenticationType]::Bearer
Token = $accessToken
Form = $formContents
}
[BasicHtmlWebResponseObject]$htmlResponse = Invoke-WebRequest @requestParameters