Kevin Allitt Posted April 24, 2024 Posted April 24, 2024 xmlmc_v_0.0.1.tar That is a break down of thats in that tar file, it all seams to be python 2 and I get complains for as you can see this errors with python 3 and not python 2, does anyone know where I get the python 3 libryary from as https://github.com/hornbill/pythonApiLib does not seem to be the python 3 libruary. Kind Regards Kevin
Steve G Posted April 24, 2024 Posted April 24, 2024 Hi @Kevin Allitt, The Hornbill pythonApiLib library does work with Python 3 (I've just tested it to make sure ), I just needed to install lxml using pip (see below). So you should just need to pull the lxml dependency into your Python 3 installation (looks like you already have it in your Python 2 installation, which it why the Hornbill library works there). Since the Hornbill pythonApiLib library was released, we've promoted to live the ability to send JSON payloads to the Hornbill API instead of the legacy XML payloads, so it might be easier to implement your API calls directly instead of using the legacy library. Means you don't need the lxml library installing too. An example as a starter-for-ten: import requests import json endpoint = "https://your-api-subdomain.hornbill.com/yourinstanceid/xmlmc/apps/com.hornbill.servicemanager/Incidents" headers = { "Authorization": "ESP-APIKEY yourHornbillAPIKey" } payload={ "@service":"apps/com.hornbill.servicemanager/Incidents", "@method":"logIncident", "params":{ "summary":"Your incident Summary", "description":"Your incident Description", "status":"status.open", }, } response = requests.request("POST", endpoint, json=payload, headers=headers) print(response.text) Hope this helps, Steve
Kevin Allitt Posted April 29, 2024 Author Posted April 29, 2024 I did the below import requests import json endpoint = "https://XXXXXXX.hornbill.com/XXXXXX/xmlmc/apps/com.hornbill.servicemanager/Requests" headers = { "Authorization": "ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXX" } payload={ "@service":"apps/com.hornbill.servicemanager/Requests", "@method":"logRequest", "params":{ "summary":"Test ScienceLogic summary Test", "description":"Test ScineceLogic Test", "requestType":"Incident", "serviceId":"11", "catalogId":"39" }, } response = requests.request("POST", endpoint, json=payload, headers=headers) print(response.text) I get the below as an output which cannot be right. <doctype html> <html ng-app2="core"> <!-- ng-csp --> <head> <base href=""> <script type="text/javascript"> // Non Supported Browser Redirect: var isUnsupportedBrowser = false, browserAgent = window.navigator.userAgent, offsetVersion, BROWSER_SAFARI_MIN_VER=14, BROWSER_FIREFOX_MIN_VER=100; if(/MSIE|Trident/.test(browserAgent)){// IE or old Edge Check: isUnsupportedBrowser = true; } else if ((offsetVersion = browserAgent.indexOf("Safari")) != -1) {// Safari Check + get Version var ix, browserVersion = browserAgent.substring(offsetVersion + 7); if ((offsetVersion = browserAgent.indexOf("Version")) != -1){ browserVersion = browserAgent.substring(offsetVersion + 8); } if ((ix = browserVersion.indexOf(";")) != -1){ browserVersion = browserVersion.substring(0, ix); } if ((ix = browserVersion.indexOf(" ")) != -1){ browserVersion = browserVersion.substring(0, ix); } browserVersion = parseInt(browserVersion); if(browserVersion && browserVersion<=BROWSER_SAFARI_MIN_VER){ // If is Safari lower than 13 then is not supported isUnsupportedBrowser = true; } } else if(browserAgent.indexOf('Firefox') !== -1){ var matches = browserAgent.match(/Firefox\/([0-9]+\.*[0-9]*)/); if (matches) { browserVersion = parseInt(matches[1]); if(browserVersion && browserVersion<=BROWSER_FIREFOX_MIN_VER){ isUnsupportedBrowser = true; } } } if(isUnsupportedBrowser){ document.location.href = "/non-supported-browser.html?rel=2157"; } var instanceId = window.location.pathname.split('/')[1]; if (!instanceId) { window.location.replace("https://www.hornbill.com"); } var coreBuild = "2157"; var deploymentMode = "deployment_mode:production"; var esp = { core: { build: coreBuild === "@" + "@" + "**core.build**" ? "0" : coreBuild, name: "Collaboration UI", version: "2.5.0", buildTime: "2024-04-24T09:10:59.622Z" }, ui: {}, initLoader : { startTime: Date.now(), steps: 10, currentStep: 1, isDev: false, setDevMsg: function(msg, msg2){ if(!esp.initLoader.isDev) return; const msgEl = document.getElementById("js-loading-screen-msg"); if(msgEl) msgEl.innerText = msg; if(msg2){ const msg2El = document.getElementById("js-loading-screen-msg-2"); if(msg2El) msg2El.innerText = msg2; } }, nextStep: function(){ const currStep = esp.initLoader.currentStep++; const progresEl = document.querySelector("progress.loading-status"); if (progresEl) { progresEl.max = esp.initLoader.steps; document.querySelector("progress.loading-status").value = currStep; } } }, loadAuth: async function() { await esp.internalLib.resourceLoader.many(["app/login/auth.js?rel=2157"]); } }; esp.appPath = document.location.protocol+"//"+document.location.hostname+"/~"+esp.core.build; var loc = window.location.protocol + '//' + window.location.host + "/" + window.location.pathname.split('/')[1] + "/"; var baseTag = document.getElementsByTagName('base')[0]; baseTag.href = loc; </script> <title>Hornbill</title> <meta name="theme-color" content="#F5F5F5" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=0.3, user-scalable=1" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <link rel="icon" type="image/png" xhref="lib/shared-Images/hornbill/favicon.ico" id="_favicon1"> <link rel="icon" type="image/png" sizes="192x192" xhref="lib/shared-Images/hornbill/Hornbill_favicon_192x192.png?rel=2157" id="_favicon2"> <!-- Loading --> <style> body{ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 14px; line-height: 1.42857143; color: #333; background-color: #fff; margin: 0; } html,body,#js-loading-screen{ height: 100%; } #js-loading-screen{ display: flex; align-items: center; justify-content: center; flex-direction: column; } #js-loading-screen img { animation: js-loading 2s linear infinite alternate; height: 96px; width: 96px; margin-bottom: 1rem; } #js-loading-screen label.loading-status-msg { font-family: sans-serif; font-size: 12px; font-weight: 500; color: #888; } #js-loading-screen progress.loading-status{ -webkit-appearance: none; -moz-appearance: none; appearance: none; width: 100%; height: 5px; border: none;/* Firefox */ position: fixed; top: 0; } #js-loading-screen progress.loading-status::-webkit-progress-bar{ background-color: #e9e9e9; border-radius: 3px; } #js-loading-screen progress.loading-status::-webkit-progress-value{ background-color: #F2892B; border-radius: 3px 0 0 3px; } #js-loading-screen progress.loading-status::-moz-progress-bar{ background-color: #F2892B; border-radius: 3px 0 0 3px; } /* Chrome, Safari, Opera */ @-webkit-keyframes js-loading { 0% { opacity: 1; -webkit-transform: rotate(0deg) scale(.5,.5); /* Chrome, Safari, Opera */ } 100% { -webkit-transform: rotate(360deg) scale(1,1); /* Chrome, Safari, Opera */ opacity: 0; } } /* Firefox */ @-moz-keyframes js-loading { 0% { opacity: 1; -moz-transform: rotate(0deg) scale(.5,.5); /* Chrome, Safari, Opera */ } 100% { -moz-transform: rotate(360deg) scale(1,1); /* Chrome, Safari, Opera */ opacity: 0; } } /* Standard syntax */ @keyframes js-loading { 0% { opacity: 1; transform: rotate(0deg) scale(.5,.5); } 100% { transform: rotate(360deg) scale(1,1); opacity: 0; } } </style> <script> if (window.self !== window.top) { var style = document.createElement("style"); style.appendChild(document.createTextNode("")); style.innerHTML = ".theme-default .hb-topnavbar { display:none !important; }"; style.innerHTML += ".body-row { margin-top:0 !important; }"; style.innerHTML += "#app-wrapper .right-slide-bar { top:0 !important; }"; style.innerHTML += ".right-slide-bar-buttons { top:0 !important; }"; document.head.appendChild(style); } document.addEventListener("DOMContentLoaded", function (event) { var element = document.createElement("script"); element.src = esp.appPath+"/app/esp.bootstrap.js?rel=2157"; document.body.appendChild(element); }); document.querySelector("#_favicon1").href = "lib/shared-Images/hornbill/favicon.ico"; document.querySelector("#_favicon2").href = "lib/shared-Images/hornbill/Hornbill_favicon_192x192.png?rel=2157"; </script> </head> <body id="app-wrapper" ng-controller="GlobalController as gc" ng-class="{'translation-mode-on':gc.isTranslationMode, 'is-right-side-bar-open':gc.isRightSlideBarOpen, 'large-slidebar':gc.rightSlideBarLarge, 'slidebar-sm': gc.rightSlideBarWidthNr <= 350, 'slidebar-md': gc.rightSlideBarWidthNr > 350 && gc.rightSlideBarWidthNr < 450, 'slidebar-lg': gc.rightSlideBarWidthNr >= 450, 'is-edge':gc.isEdge, 'is-ie':gc.isIE, 'show-plugins-style':gc.showPluginsStyle, 'use-new-main-nav':true, 'use-old-main-nav':false, 'use-light-mode':!gc.useDarkMode && !gc.useHighContrastMode, 'use-dark-mode':gc.useDarkMode, 'use-high-contrast-mode':gc.useHighContrastMode, 'account-class-basic':gc.accountType==='basic', 'is-portal-view':gc.isPortalView, 'auto-hide-header':gc.autoHideHeader}" lang="{{::gc.currentLanguageSimple}}" hb-right-click="translateString" hb-mouseover="hb-popover" delegate-selector=".translation-mode-on .hb-translate" class="{{::'bootstrap-'+$root.BOOTSTRAP_VERSION+' presentation-stream-'+gc.presentationStream+' theme-'+(gc.styleTheme||'default') + (gc.isMobileDevice?' is-mobile-device':' is-not-mobile-device')}} dkl"> <audio id="mainAudioPlayer"> <source id="mainAudioPlayerMpegSource" type="audio/mpeg"> </audio> <!--[if lte IE 10]><p>You are using an unsupported browser</p><![endif]--> <toasty></toasty> <div id="angular-app-container" hb-delegated-popover popover-config="gc.popoverConfig" style="display: none;"> </div> <div class="app-busy-container" ng-if="gc.isAppBusy" ng-class="{'active' : gc.isAppBusyActive}"> <div class="app-busy-loading"> <hb-loading loading="true" message="'Loading'|hbTranslate:'user.core.loading'"></hb-loading> </div> </div> <div id="mainModalMask"></div> <div id="SkypeButton"></div> <div id="js-loading-screen" class="text-center padding-full hb-loading" style="text-align: center;"> <img x-src="lib/shared-Images/hornbill/hornbill-logo.svg?rel=2157" id="_loadingImg1"> <progress class="loading-status" max="0" value="0"></progress> <label class="loading-status-msg" id="js-loading-screen-msg"></label> <label class="loading-status-msg" id="js-loading-screen-msg-2"></label> </div> <!--[if IE]> <script> alert("IE") window.isIE = true; </script> <![endif]--> <script> document.querySelector("#_loadingImg1").src = "lib/shared-Images/hornbill/hornbill-logo.svg?rel=2157"; </script> </body>
Steve Giller Posted April 29, 2024 Posted April 29, 2024 I would strongly suspect that you've not used the correct endpoint, if that's the response.
Kevin Allitt Posted April 30, 2024 Author Posted April 30, 2024 This is our url endpoint = "https://live.hornbill.com/pasm/xmlmc/apps/com.hornbill.servicemanager/Requests"
Steve G Posted April 30, 2024 Posted April 30, 2024 @Kevin Allitt live.hornbill.com is domain for the Hornbill UI, hence why you're getting a load of HTML and JavaScript back You can get the API endpoint for your instance from the Configuration area > Hornbill Solution Center > Your Usge > Support, as per the API Documentation. Cheers, Steve 1
Kevin Allitt Posted April 30, 2024 Author Posted April 30, 2024 This now works thank you { "@status": true, "params": { "requestId": "IN00170762", "summary": "Test ScienceLogic summary Test" }, "flowCodeDebugState": { "executionId": "b28d5892-d651-425f-994a-860ee2abbf50" } } 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now