Jump to content

Ben Paddick

Hornbill Users
  • Posts

    26
  • Joined

  • Last visited

Posts posted by Ben Paddick

  1. Hi @Ehsan

    Thank you for getting back to me.

    FYI - I am using the Power Shell module to interact with the API.

    If I test with trying to update "h_external_ref_number" and/or "h_description" I do not get any errors back.

    These are the values:

    $xmlmcOutput.status = "ok"
    $xmlmcOutput.error = NULL
    $xmlmcOutput.exceptionName = NULL
    $xmlmcOutput.exceptionDescription = NULL

    I have cut the script right back to just the following f

    Add-Param "requestId" "SR00167255"
    #Add-Param "h_summary" "Summary blah blah again"
    Add-Param "h_description" "description blah blah again"
    Add-Param "h_external_ref_number" "1234567" 
    #Add-Param "customFields" "{"h_custom_p": "someValueA"}"
     
    # Invoke XMLMC call - Get all Service Request that match search query, output returned as PSObject
    $xmlmcOutput = Invoke-XMLMC "apps/com.hornbill.servicemanager/Requests" "update"
    # Read output status
        
        if($xmlmcOutput.status -eq "ok") {  
            
                "No error returned - here are outputs"
                "API Call Status : " + $xmlmcOutput.status
                "APIError Returned  : " + $xmlmcOutput.error
                "API Excption Name : " + $xmlmcOutput.exceptionName
                "API Excption Description  : " + $xmlmcOutput.exceptionDescription
            
                }
     
            else {
     
                "An error was returned - here are outputs"
                "API Call Status : " + $xmlmcOutput.status
                "APIError Returned  : " + $xmlmcOutput.error
                "API Excption Name : " + $xmlmcOutput.exceptionName
                "API Excption Description  : " + $xmlmcOutput.exceptionDescription
            }

    I am running the connection to the API using an API key for my account. I believe this should therefore have the same permissions as what I do via the GUI?

    Any further ideas? Does this work for you within your instance?

    Many thanks

    Ben

     

     
  2. So I have tested the API "update" method Ehsan has kindly suggested. 

    The method accepts the request parameters but does not update the actual details of the SR.

    I have tried using " requestId" with combination of the following optional parameters "h_summary", "h_description", " h_external_ref_number" and "customFields".

    Looks like a bug to me as the other request update API mehtods like Hi updateReqTimeline work fine.

    Maybe an expert like @Steve G can shed some light?

  3. I have a scenario where I would like to post text data capture from a client into a Service Request through the API.

    At present I would like to use either 

    1) A request custom attribute to store the data 

    Not sure of what Hornbill Service Manager Requests function is best to do this.

    or 

    2) A request activity stream entry with a specific type

    I have successfully done this using  "https://api.hornbill.com/apps/com.hornbill.servicemanager/Requests?op=updateReqTimeline"

    However, once the data is posted I then want to be able to search / find the values via the API

    For both scenarios above I am not sure of the correct Requests function to do this.

    Any assistance would be greatly appreciated.

    Kind Regards

    Ben

     

  4. Hi.

     

    When trying to update the sub status of an SR using "Operation - com.hornbill.servicemanager/Requests::smUpdateStatus" I get the following message:

    API Call Status : fail
    Error Returned  : FlowCode Exception (com.hornbill.servicemanager/entities/Requests/fc_ops/smUpdateSubstatus): nodeName: Set the Output; nodeId: 0a2e4bdf-e634-46a5-afc2-39a985bebbb2; At 264/
    1: "Uncaught TypeError: Cannot read property 'activityId' of undefined"
        throw(e);
    _fc_node_exec_0a2e4bdf_e634_46a5_afc2_39a985bebbb2

     

    When trying to update the sub status of an SR using "Operation - com.hornbill.servicemanager/Requests::smUpdateStatus" the sub status does not change and no error is produced.

    I am however able to successfully change the status of the SR (Open > On Hold > Open).

    When using this method i submit both Status and Sub Status ID.

    Any ideas? There does not appear to be much to go wrong within the request. So is this an API bug or a back end configuration issue?

    Many Thanks

    Ben

     

  5. 24 minutes ago, Steve G said:

    Hi @Ben Paddick,

    I'm good thanks, hope you are too.

    This is the API you're after: https://api.hornbill.com/apps/com.hornbill.servicemanager/Questions?op=queryExec

    And an example of its use, to return paginated questions and answers for a specific request (SR00000513 in this example): 

    
    <methodCall service="apps/com.hornbill.servicemanager/Questions" method="queryExec">
    	<params>
    		<queryName>getRequestQuestions</queryName>
    		<requestId>SR00000513</requestId>
    		<rowstart>0</rowstart>
    		<limit>10</limit>
    		<resultType>allData</resultType>
    		<answerType>all</answerType>
    	</params>
    </methodCall>

    Cheers,

    Steve

    @Steve G thank you so much!!! 

  6. Hi all,

    I am trying to automate the export of request data and more importantly the responses to questsions using APIs.

    So far I can get all requests that match search query using : "apps/com.hornbill.servicemanager/Requests" "searchRequests"

    I can then loop through each request getting various details using : "apps/com.hornbill.servicemanager/Requests" "smGetReqDetails2"

    This enables me to return the number of questions completed but not the actual responses. Is there another API that has this feature that I can't find?

    Many Thanks

    Ben

     

     

  7. @AlexTumber

    Hi Alex - Let's start with debugging this script (GetProject) as i think the error is likely be related to why my create task fails.

    Is the syntax of the projectID field valid? I still get an error "API Outcome: failure - the specified project does not exist or you have no access to it"

    I presume its either a permissions issue or me supplying an incorrect projectID value. The last sems hard to believe as its a only 3 digit value ("277").

    Thanks

    ## Powershell Hornbill XMLMC Module 
    ## Get Single project details from Hornbill instance
    ## See the API documentation for a full list of supported API input parameters:
    ## https://api.hornbill.com/apps/com.hornbill.projectmanager/Projects?op=getProject
    
    # Import Hornbill XMLMC Powershell Module
    Import-Module "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\powershellHornbillAPIModule-master\xmlmcModule.psm1"
    
    # Define instance connection details & API key for session authentication
    $hbInstance = "vinci"
    $hbZone     = "eur"
    $hbAPIKey   = "mykeyis here"
    Set-Instance -Instance $hbInstance  -Key $hbAPIKey -Zone $hbZone
    
    # Build XMLMC API call
    
    Add-Param "projectID" "277"
    #Add-Param "returnBpmDetails" "1"
    
    # Invoke XMLMC call, output returned as PSObject
    $xmlmcOutput = Invoke-XMLMC "apps/com.hornbill.projectmanager/Projects" "getProject"
    
     if($xmlmcOutput.status -eq "ok") {
            
            # Confirm if API searched
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
            "API Status: " + $xmlmcOutput.Status
            "API Outcome: " + $xmlmcOutput.params.outcome
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
            "Projects Details: " + $xmlmcOutput.params.projectDetails
            "Projects BPM Details: " + $xmlmcOutput.params.projectBPMDetails
            "Projects Risk Details: " + $xmlmcOutput.params.projectRiskWeighting
            "Projects Total Cost Details: " + $xmlmcOutput.params.projectTotalCost
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    
        } 
    
    else {
        # API call status not OK - return status and error to console
        "API Call Status : " + $xmlmcOutput.status
        "Error Returned  : " + $xmlmcOutput.error
    }
    
    # Important! Remove XMLMC module from memory for security once XMLMC calls complete
    Remove-Module xmlmcModule

     

  8. FYI - This is the latest version of the script 

    ## Powershell Hornbill XMLMC Module Example
    ## Add project task as defined in script to your Hornbill instance
    ## See the API documentation for a full list of supported input parameters:
    ## https://api.hornbill.com/apps/com.hornbill.projectmanager/ProjectTasks?op=addProjectTask
    
    # Import Hornbill XMLMC Powershell Module
    Import-Module "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\powershellHornbillAPIModule-master\xmlmcModule.psm1"
    
    # Define instance connection details & API key for session authentication
    $hbInstance ="vinci"
    $hbZone     = "eur"
    $hbAPIKey   = "mykey"
    Set-Instance -Instance $hbInstance  -Key $hbAPIKey -Zone $hbZone
    
    # Define Project Tasks details - replace with values from CSV file later
    $projectID = "277"
    $TaskName = "this is a test project task"
    $file = get-content "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\Scripts\statuses.json"
    
    # Check the JSON values are correct on screen
    $JsonOutcomes = $file
    write-host $JsonOutcomes
    
    # Build XMLMC API call to add project task record
    Add-Param "projectID" "$projectID"
    Add-Param "name" "$TaskName"
    Add-Param "outcomes" "$JsonOutcomes"
    
    # Invoke XMLMC call, output returned as PSObject
    $xmlmcOutput = Invoke-XMLMC "apps/com.hornbill.projectmanager/ProjectTasks" "addProjectTask"
    
     if($xmlmcOutput.status -eq "ok") {
    
             "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
            "API Status: " + $xmlmcOutput.Status
            "API Outcome: " + $xmlmcOutput.params.outcome
            "New project task ID : " + $xmlmcOutput.params.projectTaskId
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    
    }
    
    else {
            # API call status not OK - return status and error to console
            "API Call Status : " + $xmlmcOutput.status
            "Error Returned  : " + $xmlmcOutput.error
        }
    
    # Important! Remove XMLMC module from memory for security once XMLMC calls complete
    Remove-Module xmlmcModule

     

  9. @AlexTumber 

    Ok the API now responds correctly (thanks). However its not yet able to create a task. It responds with "the specified project task does not exist".

    If I use the projectID value returned to me within getProject it returns "failure - the specified project task does not exist".

    So I presume its either a permissions issue or me supplying an incorrect projectID value. The last sems hard to believe as its a only 3 digit value ("277").

    The projectID I am using is the value within H_ID returned by during addProject. I am the project manager on the project so should have relevant permissions.

    Any  ideas?

    Thanks

    • Like 1
  10. Alex

    I have ammended the JSON to the following for purpose of test

    [ 	
    {"outcome":"completed","text":"Completed","language":"en-GB","buttonColor":"primary","requiresReason":"false"}
    ]

    The script has been tweaked to call this so now stands as 

    ## Powershell Hornbill XMLMC Module Example
    ## Add project task as defined in script to your Hornbill instance
    ## See the API documentation for a full list of supported input parameters:
    ## https://api.hornbill.com/apps/com.hornbill.projectmanager/ProjectTasks?op=addProjectTask
    
    # Import Hornbill XMLMC Powershell Module
    Import-Module "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\powershellHornbillAPIModule-master\xmlmcModule.psm1"
    
    # Define instance connection details & API key for session authentication
    $hbInstance ="vinci"
    $hbZone     = "eur"
    $hbAPIKey   = "key in here"
    Set-Instance -Instance $hbInstance  -Key $hbAPIKey -Zone $hbZone
    
    # Define Project Tasks details - replace with a CSV loop
    $projectID = "273"
    $name = "this is a test project task"
    $file = get-content "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\Scripts\statuses.json"
    
    $JsonOutcomes = $file
    write-host $JsonOutcomes
    
    # Build XMLMC API call to add project task record
    Add-Param "projectID" "$projectID"
    Add-Param "name" "$name"
    Add-Param "outcomes" "$JsonOutcomes"
    
    # Invoke XMLMC call, output returned as PSObject
    $xmlmcOutput = Invoke-XMLMC "apps/com.hornbill.projectmanager/Projects" "addProjectTask"
    
    "status code: " + $xmlmcOutput.status
    "New project task outcome : " + $xmlmcOutput.params.outcome
    "New project task ID : " + $xmlmcOutput.params.projectTaskId
    
    if($xmlmcOutput.status -ne "ok" -or !$xmlmcOutput.params.rowData){
        if($xmlmcOutput.status -eq "ok") {
            "No matching project task records found!"
        } else {
            # API call status not OK - return status and error to console
            "API Call Status : " + $xmlmcOutput.status
            "Error Returned  : " + $xmlmcOutput.error
        }
    }
    
    # Important! Remove XMLMC module from memory for security once XMLMC calls complete
    Remove-Module xmlmcModule

    I still recieve "Error Returned  : Failed to load FlowCode script '\\?\D:\Hornbill\ESP Server\instances\vinci\apps\com.hornbill.core\entities\Projects\fc_ops\addProjectTask.xml'"

    Any further ideas?

    Thanks

  11. Hi.

    I am trying to ADD / UPDATE project tasks using the various API functions.

    I receive a similar error for both functions

    API Call Status : fail
    Error Returned  : Failed to load FlowCode script '\\?\D:\Hornbill\ESP Server\instances\vinci\apps\com.hornbill.core\entities\Projects\fc_ops\addProjectTask.xml'

    The script i am using for the ADD task is 

    ## Powershell Hornbill XMLMC Module Example
    ## Add project task as defined in script to your Hornbill instance
    ## See the API documentation for a full list of supported input parameters:
    ## https://api.hornbill.com/apps/com.hornbill.projectmanager/ProjectTasks?op=addProjectTask
    
    # Import Hornbill XMLMC Powershell Module
    Import-Module "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\powershellHornbillAPIModule-master\xmlmcModule.psm1"
    
    # Define instance connection details & API key for session authentication
    $hbInstance ="vinci"
    $hbZone     = "eur"
    $hbAPIKey   = "myprivatekeyisinhere"
    Set-Instance -Instance $hbInstance  -Key $hbAPIKey -Zone $hbZone
    
    # Define Project Tasks details - replace with a CSV loop
    $projectID = "273"
    $name = "this is a test project task"
    $file = "C:\Users\paddickb\OneDrive - Vinci Construction UK\Hornbill\Scripts\statuses.json"
    
    # Get statuses from JSON file ["Active", "Cancelled", "Completed"]
    $JsonOutcomes = $file
    $JsonOutcomes = $JsonOutcomes | ConvertTo-Json
    
    # check the JSON has been loaded and is correct
    Write-Host $JsonOutcomes
    
    # Build XMLMC API call to add project task record
    Add-Param "projectID" "$projectID"
    Add-Param "name" "$name"
    Add-Param "outcomes" "$converted"
    
    # Invoke XMLMC call, output returned as PSObject
    $xmlmcOutput = Invoke-XMLMC "apps/com.hornbill.projectmanager/Projects" "addProjectTask"
    
    "status code: " + $xmlmcOutput.status
    "New project task outcome : " + $xmlmcOutput.params.outcome
    "New project task ID : " + $xmlmcOutput.params.projectTaskId
    
    if($xmlmcOutput.status -ne "ok" -or !$xmlmcOutput.params.rowData){
        if($xmlmcOutput.status -eq "ok") {
            "No matching project task records found!"
        } else {
            # API call status not OK - return status and error to console
            "API Call Status : " + $xmlmcOutput.status
            "Error Returned  : " + $xmlmcOutput.error
        }
    }
    
    # Important! Remove XMLMC module from memory for security once XMLMC calls complete
    Remove-Module xmlmcModule

    I presume I am doing something wrong? Most likely to do with the validation of the "Statuses"??? 

    The JSON file looks like this

    [  
       "Active",
       "Cancelled",
       "Completed"
    ]

    Any ideas? 

    I really want to be able to resolve this so I can Create / Update project tasks dates and information in bulk using excel.

    Many Thanks

    Ben

     

     

×
×
  • Create New...