Jump to content

Recommended Posts

Posted

I've just been looking into the requests/updateReqTimeline API and noticed that despite successfully posting to the timeline, the API still returns an error.

Cannot convert value "<?xml version="1.0" encoding="utf-8" ?>
<methodCallResult status="ok">
    <params>
        <outcome xs:nil="true"/>
        <activityId>urn:buzz:activity:</activityId>
        <exceptionName xs:nil="true"/>
        <exceptionDescription xs:nil="true"/>
    </params>
    <flowCodeDebugState>
        <executionId></executionId>
    </flowCodeDebugState>
</methodCallResult>
" to type "System.Xml.XmlDocument". Error: "'xs' is an undeclared prefix. Line 4, position 12.

(Not sure if they could be used for anything, but I've removed the buzz activity and execution IDs just in case)

For reference, I filled in the Request ID, Content and Visibility parameters (only Request ID and Content are required according to documentation).

On a side note, I am still finding that when I try to add a new API rule to an existing API key, this doesn't usually work (invoking the newly added API returns "The API key specified is not authorized to invoke this operation"). When I add a new rule I always reset the HB instance in a fresh PowerShell tab. I can also confirm I have not entered the rule incorrectly because, when I create a new API key and copy and paste the rules exactly, it then works with the newly created key. Just wanted to check if this is a known issue with old API keys?

Posted

Hi @CraigP,

Actually, the API is NOT producing an error.

The XML decoder IS producing the error - it can't handle the XML returned (the exact problem is the usage of "xs"-prefix in the attribute naming.

JSON is the preferred form of communication. You might want to set the Accept-header to force it to application/json

  • 4 weeks later...
Posted

Thanks @SamS

Sorry if I'm being a bit daft, but where do I add that header within the HornbillAPI PowerShell module's syntax?

Here is how I'm currently invoking the API:

Add-HB-Param "requestId" "$requestID"
Add-HB-Param "content" "$post"
Add-HB-Param "visibility" "colleague"

Invoke-HB-XMLMC "apps/com.hornbill.servicemanager/Requests" "updateReqTimeline"

Posted

Hi @CraigP,

The PowerShell API library is using XMLMC. It would need to be rewritten/or a different one should be created to use JSON objects.

Posted

@CraigP I would simply use the API directly and bypass the library altogether...

$Endpoint = "https://api.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Requests"
$Body = @{
    "@service" = "apps/com.hornbill.servicemanager/Requests"
    "@method" = "updateReqTimeline"
    params = @{
        requestId = "xs:string"
        action = "xs:string"
        source = "xs:string"
        content = "xs:string"
        extra = "xs:string"
        visibility = "xs:string"
        imageUrl = "xs:string"
        activityType = "xs:string"
        skipBpm = "xs:boolean"
    }
}
$Header = @{
    "Authorization" = "ESP-APIKEY yourHornbillAPIKey"
}
$Parameters = @{
    Method      = "POST"
    Uri         = $Endpoint
    Headers     = $Header
    Body        = ($Body | ConvertTo-Json)
    ContentType = "application/json"
}
Invoke-RestMethod @Parameters

https://docs.hornbill.com/servicemanager-api-api/entities/requests/espflowcodeentityoperation/content/updateReqTimeline

Posted

Thanks Victor

I had looked into using the API directly as per the code example on the API page, but (following updating the code with our endpoint and API key) I get an error - "Invalid session. Please establish a session first". Do I need to call something else first? Perhaps whatever the equivalent is of the "Set-HB-Instance" cmdlet from the module?

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...