Perceptive Content Integration API - Update Document Metadata (Name change)

This article demonstrates how a custom application can update document metadata from the Perceptive Content Integration API through a few code examples. This call does not seem to affect or change custom properties or notes even though the vendor documentation includes that info. Always open a session before calling the Integration API and close it afterwards (https://kb.wisc.edu/ecms/102520).

Update Document Metadata

/// <summary>
/// Helper for making a PUT 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> PutRequest(string url, string postData = null) //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 PUT request
        HttpResponseMessage response = await client.PutAsync(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;
    }
}


/// <summary>
/// Update document metadata for the given document ID.  In testing I was not able
/// to get custom properties or the notes field to update using this call.
/// The LocationID field in the postdata is the ID of the drawer or folder the doc resides 
/// 
/// https://docs.hyland.com/Developer/IS/en_US/7.4/operations.html#call_Document_V3_PUT-document-id
/// </summary>
/// <param name="DocID">ID of target document</param>
/// <param name="Doc">Object containing all document fields to be updated</param>
/// <returns></returns>
public static async Task<Document> UpdateDocument(string DocID, DocumentPost Doc)
{
    //Convert incoming data to string
    string postData = JsonConvert.SerializeObject(Doc);

    //Send PUT request with data payload
    var retval = await PutRequest(BaseURL + $"v3/document/{DocID}", postData);

    //Parse the JSON to object
    var json = JsonConvert.DeserializeObject<Document>(retval);  

    return json;
}

    


KeywordsPerceptive Content Integration API Update Document Metadata Name change   Doc ID102940
OwnerNick W.GroupECMS
Created2020-06-10 11:23:24Updated2020-06-10 11:27:18
SitesECMS
Feedback  0   0