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 {
        [Parameter(Mandatory = $true)]
        [Parameter(Mandatory = $false)]
        [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);

    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

  • Can you provide an example of the actual script you are running? From the documentation link you provided, there is more to it than just the function Get-CreativeExchangeImportResponse. – Michael West May 15 '20 at 19:37
  • Hi Michael, I tried to run the script as described in the doc: /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 the ce-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 – Simon May 17 '20 at 8:31
  • I cannot 100% confirm yet, but my guess for now, that it has something to do with the context. I retried and checked all parameters again and now the script at least works, when triggered via Web Api (also as described in the doc) However I still get the same error, when running the script in Powershell ISE – Simon May 18 '20 at 8:37
  • Conceptually, we use Creative Exchange Live as a design time process and not at build time. The front-end devs have it so that the theme updates get pushed into the Sitecore Media library via gulp watchers, and then Unicorn manages the data from there. This is a much simpler model than trying to import content into Sitecore mid-CI/CD build I would think. Perhaps you are trying to solve a problem you shouldn't even have? – Richard Hauer May 28 '20 at 15:12

I got a very similar issue, but with Sitecore SXA Creative Exchange content export. It looks like the reason is the same here.

Get-CreativeExchangeImportResponse executes ceImport.import pipeline.

ceImport.import pipeline requires initialization of ImportArgs

ImportArgs need to have HttpContext to be initilized.

It means that we need to execute Sitecore Powershell script with HttpContext, otherwise it will throw an exception.

It means that we if you are using Sitecover Powershell ISE: by default, the script executes as a background job. You can try to click on dropdown under Execute button and select "Execute in http request context"

enter image description here

And if we execute Sitecore Powershell as a remote script then we should not use -AsJob parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.