MichaelQ Super Contributor.
Super Contributor.

ServiceAPI Record.ImportHistory

Hi all,

Does anyone have a sample of how to use Record.ImportHistory via the ServiceAPI?  We can generate a serialization error but I'm quite sure that's not what we're after.

I can only assume that it wants some JSON but the format is a mystery to me.

Any and all help appreciated!

4 Replies
Super Contributor.. davros29 Super Contributor..
Super Contributor..

Re: ServiceAPI Record.ImportHistory

Here's an example in PowerShell that works for me.


# Force TLS 1.2 (thank you <a href="https://stackoverflow.com/questions/32355556/powershell-invoke-restmethod-over-https" target="_blank">https://stackoverflow.com/questions/32355556/powershell-invoke-restmethod-over-https</a>)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Create a new online audit log entry
$baseURL = 'https://url-of-your-serviceapi/cmserviceapi'
$RecordUri = 1273
$path = 'record'
$jsonActionsToCall = @{'ImportHistoryActiveEventType'='NumberChanged';'ImportHistoryHistoryLogin'='AbbottP';'ImportHistoryHistoryDescription'='Testing Service API';'ImportHistoryHistoryLocation'='12345';'HistoryIsSecurityViolation'='false';'ImportHistoryHistoryDate'="$(Get-Date)"}
$jsonBody = @{"Uri"=$RecordUri;'ImportHistory'=$jsonActionsToCall} | ConvertTo-Json -Compress
Invoke-RestMethod `
    -Method Post `
    -UseDefaultCredentials `
    -Uri "$baseURL/$path" `
    -ContentType 'application/json' `
    -Body $jsonBody    


Hope that helps. I just passed a URI for the HistoryLocation value. Not sure if that was right, but it doesn't bomb out.


Micro Focus Expert
Micro Focus Expert

Re: ServiceAPI Record.ImportHistory

To add to the reply above you can see a sample of any Service action ( which roughly equates to an SDK method) via the Service Actions samples at: /ServiceAPI/examples/ServiceActionsTryItOut?TrimType=Record


For example:


import history.png

Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
MichaelQ Super Contributor.
Super Contributor.

Re: ServiceAPI Record.ImportHistory

Thanks Davros! Much appreciated.
I have yet to verify the solution but it's very much like what I expected. I'll get back and accept solution once verified.
MichaelQ Super Contributor.
Super Contributor.

Re: ServiceAPI Record.ImportHistory

Excellent! Great tip and thanks for writing the great samples!
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.