Downloading a PDF with API or Powershell

Hi,

Is there a way to download a published PDF using the version 25 APIs or the ISHRemote PowerShell library?

  • I have tried the example with Get-IshPublicationOutputData but get the following error. I am limiting the loop to 2, so there is not a large amount of data being crunched by the server.

    Get-IshPublicationOutputData : There is no title available.
    At C:\SDL\PowerShellScripts\GetFolderContents\Untitled2.ps1:20 char:40
    + ... onOutputs | Get-IshPublicationOutputData -IshSession $ishSession -Fol ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-IshPublicationOutputData], ArgumentException
    + FullyQualifiedErrorId : GetIshPublicationOutputData,Trisoft.ISHRemote.Cmdlets.PublicationOutput.GetIshPublicatio
    nOutputData
  • Yes there is... if you trigger the following PowerShell command: get-help get-ishpublicationoutputdata -examples
    You should see something like
    [...]
    NAME
    Get-IshPublicationOutputData

    SYNOPSIS
    The Get-IshPublicationOutputData cmdlet retrieves the data/blob of the publication output that are passed through the pipeline or
    determined via provided parameters and saves them to the given Windows folder.


    ---------- EXAMPLE 1 ----------

    $ishSession = New-IshSession -WsBaseUrl "example.com/.../" -IshUserName "username" -IshUserPassword "userpassword"
    $requestedMetadataRetrieve = Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHOUTPUTFORMATREF' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLNGCOMBINATION' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLISHER' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTARTDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBENDDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'VERSION' -Level "Version"
    $metadataFilterRetrieve = Set-IshMetadataFilterField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level 'Lng' -ValueType "Value"
    -FilterOperator "Equal" -Value "Draft"
    $publicationOutputs = Find-IshPublicationOutput -IshSession $ishSession -StatusFilter "ishnostatusfilter" -MetadataFilter
    $metadataFilterRetrieve -RequestedMetadata $requestedMetadataRetrieve
    $fileInfoArray = $publicationOutputs | Get-IshPublicationOutputData -IshSession $ishSession -FolderPath "c:\temp\export"

    Downloading publication outputs
    [...]

    On your code below, your actual code could help.
  • Thanks Dave, that is the code I used, but I get the "There is no title available." error. See my code below.

    $ishSession = New-IshSession -WsBaseUrl "ourServerLocation.sdlproducts.com/ISHWS" -IshUserName myname -IshPassword mypassword
    $requestedMetadataRetrieve = Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHOUTPUTFORMATREF' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLNGCOMBINATION' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLISHER' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FTITLE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLISHER' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTARTDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBENDDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'VERSION' -Level "Version"
    $metadataFilterRetrieve = Set-IshMetadataFilterField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level 'Lng' -ValueType "Value" -FilterOperator "Equal" -Value "Released"
    $publicationOutputs = Find-IshPublicationOutput -IshSession $ishSession -StatusFilter "ishnostatusfilter" -MetadataFilter $metadataFilterRetrieve -RequestedMetadata $requestedMetadataRetrieve

    [int] $mycounter = 0
    foreach ( $pubItem in $publicationOutputs ) {
    $mycounter = $mycounter + 1
    $fileInfoArray = $publicationOutputs | Get-IshPublicationOutputData -IshSession $ishSession -FolderPath "c:\SDSL\export"
    if ($mycounter -eq 1) {break}
    }
  • Hi Dave, I removed FTITLE since it wasn't working and removed a duplicate FISHPUBLISHER, but still get the same error.

    $ishSession = New-IshSession -WsBaseUrl "ourServerLocation.sdlproducts.com/ISHWS" -IshUserName myname -IshPassword mypassword
    $requestedMetadataRetrieve = Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHOUTPUTFORMATREF' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLNGCOMBINATION' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLISHER' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTARTDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBENDDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'VERSION' -Level "Version"
    $metadataFilterRetrieve = Set-IshMetadataFilterField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level 'Lng' -ValueType "Value" -FilterOperator "Equal" -Value "Released"
    $publicationOutputs = Find-IshPublicationOutput -IshSession $ishSession -StatusFilter "ishnostatusfilter" -MetadataFilter $metadataFilterRetrieve -RequestedMetadata $requestedMetadataRetrieve

    [int] $mycounter = 1
    foreach ( $pubItem in $publicationOutputs ) {
    $fileInfoArray = $publicationOutputs | Get-IshPublicationOutputData -IshSession $ishSession -FolderPath "c:\SDSL\export"
    if ($mycounter -eq 1) {break}
    }
  • Hi Rich

    Looking into the code I see an FTITLE is required to generate a proper filename.

    • In the above example you had Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FTITLE' -Level "Lng" |
      however FTITLE is not an Lng but Logical field. So it should have been 
      Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FTITLE' -Level "Logical" |
    • Don't know if c:\SDSL\export is a typo for SDL :)

    Please log a GitHub issue to improve the error message and/or skip the title if not presented for the FileNameHelper class.

    So my working code is

    $ishSession = New-IshSession -WsBaseUrl "https://example.com/ISHWS/" -PSCredential "Admin"
    $requestedMetadataRetrieve = Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHOUTPUTFORMATREF' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLNGCOMBINATION' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBLISHER' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBSTARTDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FISHPUBENDDATE' -Level "Lng" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'VERSION' -Level "Version" |
    Set-IshRequestedMetadataField -IshSession $ishSession -Name 'FTITLE' -Level "Logical"
    $metadataFilterRetrieve = Set-IshMetadataFilterField -IshSession $ishSession -Name 'FISHPUBSTATUS' -Level 'Lng' -ValueType "Value" -FilterOperator "Equal" -Value "Released"
    $publicationOutputs = Find-IshPublicationOutput -IshSession $ishSession -StatusFilter "ishnostatusfilter" -MetadataFilter $metadataFilterRetrieve -RequestedMetadata $requestedMetadataRetrieve
    [int] $mycounter = 1
    foreach ( $pubItem in $publicationOutputs ) {
    $fileInfoArray = $publicationOutputs | Get-IshPublicationOutputData -IshSession $ishSession -FolderPath "c:\TEMP\" -Verbose -Debug
    if ($mycounter -eq 1) {break}
    }

     

  • Out of curiosity do the publications already exist in the database or file system or are they published when this app is run? Thanks.
  • They should already be present in the database attached to the PublicationOutput (language/outputformat level of publications) entity. If you need to publish them still, have a look at the Publish-IshPublicationOutput cmdlet.

    How it is used, is shown in a (perhaps outdated, didn't verify :)) sample here: github.com/.../Publish-PublicationOutputs