I am looking for a way to either create articles in a "published" state, or trigger the "publish" workflow through the REST API.
I wrote a little PowerShell snippet that is creating the articles in "draft":
$serviceNowCredential = Get-Credential
$uri = "https://<instance>.service-now.com/api/now/table/kb_knowledge"
$method = "POST"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $ServiceNowCredential.UserName, $serviceNowCredential.GetNetworkCredential().Password)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization', ('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept', 'application/json')
$headers.Add('content-type', 'application/json')
$tempObj = [PsCustomObject]@{
text = 'Some stuff goes here'
sys_created_by = 'user@emaildomain.com'
author = 'e9326af747d9611091271c42846d43bd'
active = 'true'
kb_knowledge_base = 'cf33206447e5a11091271c42846d43ac'
topic = 'General'
short_description = 'How to do a Thing'
article_type = 'text'
kb_category = 'a196b8a44729a11091271c42846d438c'
}
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -Body ($tempObj | ConvertTo-Json) -ErrorAction Stop
That works just fine, but I don't see any way to publish the resulting article. I have tried adding a date value to the "published" and "schedueled_published_date" properties, and setting "workflow_state" to "published".
How would I switch the state or trigger the publish workflow (Instant Publish, in this case) to do the publishing? I am on Tokyo.