/// <summary>
/// Adds the document or folder to a workflow
///
/// Example POST payload json:
///
/// {
/// "objectId": "301YW2G_0006YVLZ1000011",
/// "itemType": "DOCUMENT",
/// "workflowQueueId": "301YW2G_0006YMLZ100001R",
/// "itemPriority": "MEDIUM"
/// }
///
/// </summary>
/// <param name="objectID">ID of Document or Folder being added</param>
/// <param name="workflowQueueID">ID of the target workflow</param>
public static async Task<string> AddWorkflowQueueItem(string objectID, string workflowQueueID)
{
// Create POST JSON data
var postData = "{\"objectId\": \"" + objectID + "\",\"itemType\": \"DOCUMENT\",\"workflowQueueId\": \"" + workflowQueueID + "\",\"itemPriority\": \"MEDIUM\"}";
//send the POST request with assignment data
var retval = await PostRequest(BaseURL + "workflowItem/", postData);
return retval;
}
/// <summary>
/// Helper for making a POST request to Integration Server API
/// </summary>
/// <param name="url">URL for this request</param>
/// <param name="postData">Data payload for this request, defaults to empty string</param>
private static async Task<string> PostRequest(string url, string postData = "") //post data defaults to null
{
try
{
//http client data persists so first we clear headers
client.DefaultRequestHeaders.Clear();
//API will default to returning XML if we do not
//specify the Accept header
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
//Retrieve the access token from memory and
//add it to the request as a custom header
client.DefaultRequestHeaders.Add("X-IntegrationServer-Session-Hash", Token);
//This line adds the post data and sets the content-type
//header to application/json
var data = new StringContent(postData, Encoding.UTF8, "application/json");
//Send the POST2 request
HttpResponseMessage response = await client.PostAsync(url, data);
//throws exception if not a success
response.EnsureSuccessStatusCode();
//Read the response text and return it
string responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
catch (Exception e) //if anything goes wrong end the session
{
await CloseSession();
throw;
}
}
Keywords | Perceptive Content Integration API Add Document to Workflow Queue | Doc ID | 102600 |
---|---|---|---|
Owner | Nick W. | Group | ECMS |
Created | 2020-05-28 13:22:38 | Updated | 2020-06-10 11:57:18 |
Sites | ECMS | ||
Feedback | 0 0 Comment Suggest a new document |