Programmatic API Call Examples 📰

This is an example API call In powershell to create or update a record

Powershell



########################
### Configure script ###
################################################
### Imagen requires at least TLS version 1.2
[Net.ServicePointManager]::SecurityProtocol =
[Net.SecurityProtocolType]::Tls12
#################################################

################
### Make XML ###
################
$xmlContent=@"
<?xml version="1.0" encoding="UTF-8"?>
<Records><!-- The PARENT level node containing each Record -->
<ImagenRecord><!-- The Record Node -->
    <Fields>  <!-- The Fields of your record schema -->
<!-- All mandatory fields must be included -->
          <Title>$Title</Title>
          <Description><![CDATA[$Description]]></Description>
          <Date>$Date</Date>
          <Year>$Year</Year>            
      </Fields>
  </ImagenRecord>
</Records>
"@  

#####################################################
### Set headers and arguments for REST HTTPs call ###
#####################################################
### URL
$mccHost        = "The FQDN of your Imagen platform"

### Arguments
$mappingFile    = "Your mapping file name Default {NativeImagenXML}"
$workflow       = "Your workflow name - Default 'Ingest Video'"

### Headers
$apiKey         = "Your API key goes here"
$bearer         = "Your bearer token goes here"
$headers = @{"X-Imagen-API-Key"="$apiKey";"Authorization"="Bearer $bearer"}
$contentType = "text/xml;charset=utf-8"

#########################
### attempt REST call ###
#########################

Invoke-RestMethod -uri "https://$mccHost`:83/imcc/v1/import/record/$mappingFile`?workflow=$workflow" -Headers $headers -ContentType $contentType -Method put -verbose -InFile $xmlpayloadLocation