I was trying to set up a CI/CD
according to the documentation, where I planned to trigger a Creative Exchange Import via Sitecore Powershell Extensions Web Api.
I am currently running Sitecore 9.3
on Azure PaaS
and Sitecore Powershell Extensions 6.0
I tracked the error down to a script, that came with SXA: /sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Creative Exchange/Functions/CI/Get-CreativeExchangeImportResponse
I changed the content, so I can run only the script in itself and added a function call at the bottom. Apart from that, I made no changes.
function Get-CreativeExchangeImportResponse {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[Item]$CurrentItem,
[Parameter(Mandatory = $false)]
[Sitecore.XA.Feature.CreativeExchange.Storage.CreativeExchangeStorageDefinition]$StorageDefinition,
[Parameter(Mandatory = $false )]
[int]$FileSizeLimit = 0,
[Parameter(Mandatory = $false)]
[Sitecore.Data.ID]$DeviceId = "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}"
)
begin {
Write-Verbose "Cmdlet Get-CreativeExchangeImportResponse - Begin"
# switch off Write-Progress used in Invoke-WebRequest
$progressPreference = 'silentlyContinue'
Import-Function Get-StorageDefinition
}
process {
Write-Verbose "Cmdlet Get-CreativeExchangeImportResponse - Process"
# assign default parameters
if ($StorageDefinition -eq $null) {
$StorageDefinition = Get-StorageDefinition $CurrentItem "Folder on server"
}
if ($MarkupMode -eq $null) {
$MarkupMode = [Sitecore.XA.Feature.CreativeExchange.Enums.MarkupMode]::AgencyDrop
}
if ($ExportScope -eq $null) {
$ExportScope = [Sitecore.XA.Feature.CreativeExchange.Enums.ExportScope]::Site
}
if ($BucketExportMode -eq $null) {
$BucketExportMode = [Sitecore.XA.Feature.CreativeExchange.Enums.BucketExportMode]::OneOfTemplate
}
$importArgs = New-Object -TypeName "Sitecore.XA.Feature.CreativeExchange.Pipelines.Import.Import.ImportArgs"
$importArgs.HttpContext = [System.Web.HttpContext]::Current
$importContext = New-Object -TypeName "Sitecore.XA.Feature.CreativeExchange.Models.Import.ImportContext"
$importContext.StorageServiceDefinition = $StorageDefinition
$importContext.DeviceId = $DeviceId
$importContext.Database = $CurrentItem.Database
$importContext.ImportOptions = New-Object -TypeName "Sitecore.XA.Feature.CreativeExchange.Models.Import.ImportOptions"
$importArgs.ImportContext = $importContext
[Sitecore.Pipelines.CorePipeline]::Run("ceImport.import", $importArgs);
$importArgs
}
end {
Write-Verbose "Cmdlet Get-CreativeExchangeImportResponse - End"
}
}
Get-CreativeExchangeImportResponse -CurrentItem (Get-Item -Path "/sitecore/content/Tenant/Site/Home")
As I run this script, I get the following error message
Exception calling "Run" with "2" argument(s): "Object reference not set to an instance of an object."
At line:52 char:9
+ [Sitecore.Pipelines.CorePipeline]::Run("ceImport.import", $im ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
ImportContext : Sitecore.XA.Feature.CreativeExchange.Models.Import.ImportContext
HttpContext :
CreativeExchangeStorage : Sitecore.XA.Feature.CreativeExchange.Storage.Import.FileImportStorage
Messages : {}
ThemeAssets : {}
CustomData : {}
Aborted : False
Message :
ProcessorItem :
Suspended : False
What I read from this, is that $importArgs
is not quite what the pipeline expects. I debugged through the script and $importArgs
is null or so I think and I'm not sure, what exactly the args should contain for the pipeline to run.
Has anyone experienced this error before? I'd be glad for some info or maybe a hint where to look. I guess my next step would be to decompile the pipeline itself and check what could cause this issue there.
Thanks for any hints, Simon
Get-CreativeExchangeImportResponse
./sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Creative Exchange/Web API/ce-import
and in there the script from my question is called. But in thece-import
is not much additional logic other than getting the item from the path and then calling the Get-CreativeExchangeImportResponse
function with the current item set