Kevin Allitt Posted January 21, 2022 Share Posted January 21, 2022 I'm looking for a way to perform the below tasks within science logic's Monitoring, I'm thinking of firing off Basic Curl commands from within the Linux OS ssh shell or using Python programming language. First I wonder if anyone could shed light on how to achieve this from the Linux OS using Curl a, raise a hornbill ticketb, enquire what the ticket reference number isc, update that ticketd, close that ticket. Second I'd be interested if anyone can shed light on achieving this in Phyton as well. Also our API is called https://api.hornbill.com/ , so when running this, we will not be logged in, so authentication will be needed and perhaps should be given within the curl statements. Kind Regards Kevin Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 21, 2022 Share Posted January 21, 2022 Kevin Easiest way for CURL is to use the API Key (create one against your account or create a BOT account and use the following $KEY="APIKEY" curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/keiths/xml.xml https:/mdh-p01-api.hornbill.com/INSTANCEID/xmlmc/ then in xml.xml you create the XML to do whatever you want (From the API documented in your post) So for example <methodCall service="data" method="sqlQuery"> <params> <query>Select h_pk_reference from h_itsm_requests</query> </params> </methodCall> Link to comment Share on other sites More sharing options...
Steve G Posted January 21, 2022 Share Posted January 21, 2022 @Kevin Allitt, As well as Keith's curl explanation, there are examples of how to make API calls using Python here: https://github.com/hornbill/pythonPowerBIHornbillDataSources And we also have a library for making API calls from Python easier, which lives here: https://github.com/hornbill/pythonApiLib Cheers, Steve Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 24, 2022 Author Share Posted January 24, 2022 HI, Keith, thank you for your reply, its these 4 tasks that I wish to have examples on below as trying to traverse the https://api.hornbill.com/ and find the bits that are relevant is like reading a bible to find a paragraph, you would not actually have examples for each of the below would you, I would imagine they are commonly asked for or used as these are the things most people require to do. a, raise a hornbill ticketb, enquire what the ticket reference number isc, update that ticketd, close that ticket. If you have an example of each that would be exactly what I need as my issue is understanding out of all the documentation what I really do actually need. Kind Regards Kevin Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 24, 2022 Author Share Posted January 24, 2022 HI Steve, thank you for your reply, I too already have the links that you have posted but for me its not showing you what you need to do for any of my requested examples. If you can give me Python code examples for each of the below would be useful. a, raise a hornbill ticketb, enquire what the ticket reference number isc, update that ticketd, close that ticket. Kind Regards Kevin Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 24, 2022 Author Share Posted January 24, 2022 Hi Keith, If you could help with what could be the issue below please. Kind Regards Kevin Our Instance is https://live.hornbill.com/pasm/servicemanager/requests/ So I understand the "INSTANCEID" to be "pasm". XML file is cat xml.xml <methodCall service="data" method="sqlQuery"> <params> <query>Select h_pk_reference from h_itsm_requests where h_pk_reference = "IN00099935"</query> </params> </methodCall> Location of XML file is pwd /home/kevinal kevinal@DV00393:~$ ls -l total 42508 -rw-r--r-- 1 kevinal kevinal 177 Jan 24 09:41 xml.xml Curl Call Is Can you please check that we have resolved "INSTANCEID" correctly curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/api.hornbill.com/pasm/xmlmc/ Note: Unnecessary use of -X or --request, POST is already inferred. * Unwillingly accepted illegal URL using 1 slash! * Trying 78.129.173.117... * TCP_NODELAY set * Connected to api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7fffba4f2600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/ HTTP/2 > Host: api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXX ( Replaced so we don't show Key ) > Content-Length: 177 > * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Mon, 24 Jan 2022 09:41:29 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 252 < accept-ranges: bytes < x-esp-socket-perf: accept=0.001ms, handlerCreate=0.010ms, handlerSetup=0.029ms, handlerStart=5.261ms < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: template < x-esp-transaction-id: ef70f79e3fd24a2eb33effec0bcedfbe < x-esp-request-perf: 2.958ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0004</code> <error>The XMLMC request message specifies different service than the one specified in the request URI</error> </state> </methodCallResult> * Connection #0 to host api.hornbill.com left intact Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 24, 2022 Share Posted January 24, 2022 @Kevin Allitt I missed a bit in the instructions. Add data to the end of the URL. curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/api.hornbill.com/pasm/xmlmc/data/ This service (ie data) is the first level of the below - https://mdh-p01-api.hornbill.com/pasm/xmlmc/ in which the API you are calling resides and matches the one in the XML Kind Regards Keith Stevenson Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 24, 2022 Author Share Posted January 24, 2022 Hi Keith my output was as so :- Is there something else missing ? curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/api.hornbill.c om/pasm/xmlmc/data/ Note: Unnecessary use of -X or --request, POST is already inferred. * Unwillingly accepted illegal URL using 1 slash! * Trying 78.129.173.117... * TCP_NODELAY set * Connected to api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7ffff50f1600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/data/ HTTP/2 > Host: api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 177 > * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Mon, 24 Jan 2022 12:19:58 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 252 < accept-ranges: bytes < x-esp-socket-perf: accept=0.001ms, handlerCreate=0.010ms, handlerSetup=0.034ms, handlerStart=0.295ms < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: template < x-esp-transaction-id: 9bdb384bb2a544c582cb8c3d2f15436d < x-esp-request-perf: 1.467ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0004</code> <error>The XMLMC request message specifies different service than the one specified in the request URI</error> </state> </methodCallResult> * Connection #0 to host api.hornbill.com left intact This is when I put your Prefix to the api call from https://api.hornbill.com/pasm/xmlmc/ to https://mdh-p01-api.hornbill.com/pasm/xmlmc/ curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https://mdh-p01-api.hornbill.com/pasm/xmlmc/ Note: Unnecessary use of -X or --request, POST is already inferred. * Trying 78.129.173.117... * TCP_NODELAY set * Connected to mdh-p01-api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "mdh-p01-api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7ffff3fb2600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/ HTTP/2 > Host: mdh-p01-api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 177 > * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 404 < server: nginx < date: Mon, 24 Jan 2022 12:23:45 GMT < content-length: 0 < accept-ranges: bytes < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < * Connection #0 to host mdh-p01-api.hornbill.com left intact Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 24, 2022 Share Posted January 24, 2022 @Kevin Allitt I think the problem is I commented without having enough coffeecurl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/mdh-p01-api.hornbill.com/pasm/xmlmc/data/ Should work Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 25, 2022 Author Share Posted January 25, 2022 should I be using mdh-p01-api.hornbill.com or api.hornbill.com in the https:/ and should it be / or // either/or none of them are showing that they worked. cat xml.xml <methodCall service="data" method="sqlQuery"> <params> <query>Select h_pk_reference from h_itsm_requests</query> </params> </methodCall> curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/mdh-p01-api.ho rnbill.com/pasm/xmlmc/data/ Note: Unnecessary use of -X or --request, POST is already inferred. * Unwillingly accepted illegal URL using 1 slash! * Trying 78.129.173.117... * TCP_NODELAY set * Connected to mdh-p01-api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "mdh-p01-api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7fffc32e8600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/data/ HTTP/2 > Host: mdh-p01-api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 141 > * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Tue, 25 Jan 2022 19:25:26 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 260 < accept-ranges: bytes < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: pasm < x-esp-transaction-id: 3debf15276454259a0c348505eb5b018 < x-esp-request-perf: 86.067ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0200</code> <service>data</service> <operation>sqlQuery</operation> <error>Unable to execute the specified SQL query</error> </state> </methodCallResult> * Connection #0 to host mdh-p01-api.hornbill.com left intact curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https://mdh-p01-api.h ornbill.com/pasm/xmlmc/data/ Note: Unnecessary use of -X or --request, POST is already inferred. * Trying 78.129.173.117... * TCP_NODELAY set * Connected to mdh-p01-api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "mdh-p01-api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7fffcedaa600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/data/ HTTP/2 > Host: mdh-p01-api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 141 > * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Tue, 25 Jan 2022 19:30:23 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 260 < accept-ranges: bytes < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: pasm < x-esp-transaction-id: 552a5cec25da468b825a8ea5f16e75bd < x-esp-request-perf: 77.162ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0200</code> <service>data</service> <operation>sqlQuery</operation> <error>Unable to execute the specified SQL query</error> </state> </methodCallResult> * Connection #0 to host mdh-p01-api.hornbill.com left intact curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https:/api.hornbill.c om/pasm/xmlmc/data/ Note: Unnecessary use of -X or --request, POST is already inferred. * Unwillingly accepted illegal URL using 1 slash! * Trying 78.129.173.117... * TCP_NODELAY set * Connected to api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7ffff3967600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/data/ HTTP/2 > Host: api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 141 > * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Tue, 25 Jan 2022 19:27:48 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 252 < accept-ranges: bytes < x-esp-socket-perf: accept=0.002ms, handlerCreate=0.017ms, handlerSetup=0.037ms, handlerStart=0.372ms < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: template < x-esp-transaction-id: 79bf26d377f44f779c5e9656e1cae2c7 < x-esp-request-perf: 2.365ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0004</code> <error>The XMLMC request message specifies different service than the one specified in the request URI</error> </state> </methodCallResult> * Connection #0 to host api.hornbill.com left intact curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https://api.hornbill. com/pasm/xmlmc/data/ Note: Unnecessary use of -X or --request, POST is already inferred. * Trying 78.129.173.117... * TCP_NODELAY set * Connected to api.hornbill.com (78.129.173.117) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Unknown (8): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Client hello (1): * TLSv1.3 (OUT), TLS Unknown, Certificate Status (22): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: C=GB; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com * start date: Feb 10 00:00:00 2020 GMT * expire date: Mar 27 12:00:00 2022 GMT * subjectAltName: host "api.hornbill.com" matched cert's "*.hornbill.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018 * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * Using Stream ID: 1 (easy handle 0x7fffc081d600) * TLSv1.3 (OUT), TLS Unknown, Unknown (23): > POST /pasm/xmlmc/data/ HTTP/2 > Host: api.hornbill.com > User-Agent: curl/7.58.0 > Accept: */* > Content-type: text/xmlmc;charset=utf-8 > Authorization: ESP-APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXX > Content-Length: 141 > * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * Connection state changed (MAX_CONCURRENT_STREAMS updated)! * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * TLSv1.3 (OUT), TLS Unknown, Unknown (23): * We are completely uploaded and fine * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): * TLSv1.3 (IN), TLS Unknown, Unknown (23): < HTTP/2 200 < server: nginx < date: Tue, 25 Jan 2022 19:28:55 GMT < content-type: text/xmlmc; charset=utf-8 < content-length: 252 < accept-ranges: bytes < x-esp-socket-perf: accept=0.002ms, handlerCreate=0.014ms, handlerSetup=0.038ms, handlerStart=0.990ms < x-esp-service-name: EspServerService < x-esp-service-version: < x-esp-service-build-date: < cache-control: no-cache < x-esp-instance: template < x-esp-transaction-id: dcc3fc95db5947009f1993469c50ee42 < x-esp-request-perf: 1.869ms < strict-transport-security: max-age=31536000; includeSubDomains < <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="fail"> <state> <code>0004</code> <error>The XMLMC request message specifies different service than the one specified in the request URI</error> </state> </methodCallResult> * Connection #0 to host api.hornbill.com left intact Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 26, 2022 Share Posted January 26, 2022 @Kevin Allitt From the above curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https://mdh-p01-api.hornbill.com/pasm/xmlmc/data/ Executed the API correctly , however something (Usually rights ) prevented it. You will need to check the Logs (EspApiTransaction) at the time of running to see what the "reason" was Kind Regards Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 26, 2022 Author Share Posted January 26, 2022 Logs (EspApiTransaction) ? 18111826/01/2022 15:28:43error17644 0.036985s [ERROR]:[DATABASE] The maximum number of rows allowed (25000) has been exceeded, query aborted 0.037519s [ERROR]:[PROFILE] data::sqlQuery() Method call results: failure (242262016 B, 35 ms, -20 kB, 0 ms, 0 kB) So this looks promising as it shows the API is receiving a query and its an SQL issue. What would be a really good query to send for testing ? I basically dont know anything about its database. Is there a doc showing its database Layout, I guess I should be able to Insert, Delete and Update tables with this method. Are there any restraint rules and triggers that populate tables when others are added to etc. If I want to create a ticket, what would the Query be and on which tables ? Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 26, 2022 Share Posted January 26, 2022 @Kevin Allitt The XML for SQL QUery was just an example of how to connect and send an XMLMC request. For logging calls et you will need to use the APIs under ServiceManager such as logServiceRequest (and create the XML based on whats required there ) .. The methods and expected params etc are listed in the below documentation. https://api.hornbill.com/apps/com.hornbill.servicemanager/ Kind Regards Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 26, 2022 Author Share Posted January 26, 2022 curl -v -X POST -H "Content-type: text/xmlmc;charset=utf-8" -H "Authorization: ESP-APIKEY $KEY" --data-binary @/home/kevinal/xml.xml https://mdh-p01-api.hornbill.com/pasm/xmlmc/data/ 2> /dev/null <?xml version="1.0" encoding="utf-8" ?> <methodCallResult status="ok"> <params> <rowsAffected>0</rowsAffected> <lastInsertId>0</lastInsertId> <rowData> <row> <h_pk_reference>SR00101217</h_pk_reference> <h_activity_stream_id>urn:buzz:activityStream:bd9052c7-2866-4a7b-b2a9-62de00694ba2</h_activity_stream_id> <h_archived>0</h_archived> <h_locked_details>0</h_locked_details> <h_bpm_authorised>0</h_bpm_authorised> <h_bpm_id>BPM20220120000024</h_bpm_id> <h_bpm_stage_expired>0</h_bpm_stage_expired> <h_catalog>Raise a Service Request</h_catalog> <h_catalog_id>259</h_catalog_id> <h_category>Service Request->Customer Support->Entertainment Data->TV Other</h_category> <h_category_id>425</h_category_id> <h_closedby_team_id>PressAssociation/ITOps1/</h_closedby_team_id> <h_closedby_teamname>SysOps Support</h_closedby_teamname> <h_closedby_user_id>josephe</h_closedby_user_id> <h_closedby_username>XXXX</h_closedby_username> <h_closure_category>Resolved with Technical Intervention->Service Request Delivered or Closed</h_closure_category> <h_closure_category_id>221</h_closure_category_id> <h_container_id>0</h_container_id> <h_createdby>XXX</h_createdby> <h_custom_l>2</h_custom_l> <h_customer_type>0</h_customer_type> <h_dateclosed>2022-01-20 15:24:17</h_dateclosed> <h_datelastmodified>2022-01-20 15:24:18</h_datelastmodified> <h_datelogged>2022-01-20 10:02:44</h_datelogged> <h_dateresolved>2022-01-20 15:24:16</h_dateresolved> <h_description>XXX has asked if someone generate a XXX</h_description> <h_feedback_status>not required</h_feedback_status> <h_feedback_status_id>5</h_feedback_status_id> <h_fk_priorityid>5</h_fk_priorityid> <h_fk_priorityname>Priority 2</h_fk_priorityname> <h_fk_serviceid>25</h_fk_serviceid> <h_fk_servicename>XXXData</h_fk_servicename> <h_fk_servicelevelagreementid>7</h_fk_servicelevelagreementid> <h_fk_servicelevelagreementname>XXX XXX Core Hours</h_fk_servicelevelagreementname> <h_fk_servicelevelid>0</h_fk_servicelevelid> <h_fk_team_id>XXX/ITOps1/</h_fk_team_id> <h_fk_team_name>XXXSupport</h_fk_team_name> <h_fk_user_id>XXX</h_fk_user_id> <h_fk_user_name>XXX XXX</h_fk_user_name> <h_idx_ref>XXX</h_idx_ref> <h_isanalystunread>0</h_isanalystunread> <h_ownerid>josephe</h_ownerid> <h_ownername>XXX XXX</h_ownername> <h_reopencount>0</h_reopencount> <h_request_language>en-GB</h_request_language> <h_request_prefix>SR</h_request_prefix> <h_requesttype>Service Request</h_requesttype> <h_resolution>XXX </h_resolution> <h_resolvedby_team_id>XXX/ITOps1/</h_resolvedby_team_id> <h_resolvedby_teamname>XXXSupport</h_resolvedby_teamname> <h_resolvedby_user_id>XXX</h_resolvedby_user_id> <h_resolvedby_username>XXX XXX</h_resolvedby_username> <h_site>XXX Ops</h_site> <h_site_id>29</h_site_id> <h_social_object_ref>urn:sys:entity:com.hornbill.servicemanager:Requests:XXX</h_social_object_ref> <h_social_object_urn>urn:sys:user:nickyl</h_social_object_urn> <h_source_id>1225339</h_source_id> <h_source_type>Email</h_source_type> <h_status>status.closed</h_status> <h_summary>Digiguide XX/XX Refresh</h_summary> <h_org_id>0</h_org_id> <h_last_update_activity_id>urn:buzz:activity:cbe5015e-db84-4674-9add-fb7a5e377910</h_last_update_activity_id> <h_lastmodifieduserid>XXX</h_lastmodifieduserid> <h_lastmodifiedusername>XXX XX</h_lastmodifiedusername> <h_lastmodifiedusertype>0</h_lastmodifiedusertype> <h_lastmodifiedtype>0</h_lastmodifiedtype> </row> </rowData> <queryExecTime>2738</queryExecTime> <queryResultsTime>992</queryResultsTime> </params> </methodCallResult> cat xml.xml <methodCall service="data" method="sqlQuery"> <params> <query>select * from h_itsm_requests where h_pk_reference = 'SR00101217'</query> </params> </methodCall> Link to comment Share on other sites More sharing options...
Kevin Allitt Posted January 26, 2022 Author Share Posted January 26, 2022 So Now we have access to the Database, how do you go about in SQL :- Creating a New Ticket Finding out what the New Ticket Number Is Updating that ticket Closing that ticket. Thank you for the above help on the API and gaining access we are nearly there in concept. Link to comment Share on other sites More sharing options...
Keith Stevenson Posted January 26, 2022 Share Posted January 26, 2022 @Kevin AllittAs above you need to use the Service Manager APIs not the Data SQL query (That was just so you can see using API and getting data) . Its the same concept (send XML parse the result) but different API..https://api.hornbill.com/apps/com.hornbill.servicemanager/Requests?op=logRequest etchttps://api.hornbill.com/apps/com.hornbill.servicemanager/ A good way is to mimic what the web browser does,.. In Chrome hit F12, log a call and watch the APIs being created.. Kind Regards Keith Stevenson Link to comment Share on other sites More sharing options...
Kevin Allitt Posted February 8, 2022 Author Share Posted February 8, 2022 Tried it The Steve G's way, Downloaded https://github.com/hornbill/pythonApiLib Copied the exception.py and the xmlmc.py into the current code folder, you can put it in the python pathed modules folder as well. I wrote the code below, called it all.py and ran python all.py and this created a ticket, outputted the ticket number and then updated it and then closed the ticket. So if anyone out there is stuck and struggling to work this out, this works and should work for you without having to fall down all the rabbit holes I did, and learnt a whole new set of things that are not related, if your question is how do you do it and can you have an example, then your answer is below. Remember to place your own API key and instance name in the places pointed out by X's #!/usr/bin/env python2 from xmlmc import XmlmcService from xmlmc import XmlmcHelper import sys import subprocess # # Initiate XmlmcService instance # xmlmc = XmlmcService("XXXX Your Instance Name XXXX") # # With API key (Recommended) # xmlmc.set_api_key("XXXXXX YourKey XXXXXX") # Get session info # Create The Ticket xmlmc.add_param("summary", "Test ScienceLogic summary Test") xmlmc.add_param("description", "Test ScineceLogic Test") xmlmc.add_param("requestType", "Incident") # you can change this to what ever type you have xmlmc.add_param("serviceId", "15") # you need to put your own serviceid in here xmlmc.add_param("catalogId", "39") # you need to put your own catalogid in here json_string = xmlmc.invoke("apps/com.hornbill.servicemanager/Requests", "logRequest") if XmlmcHelper.is_call_success(json_string): requestId = XmlmcHelper.get_param_value(json_string, "params/requestId") print(requestId) else: print(XmlmcHelper.get_error_message(json_string)) # Now Update xmlmc.add_param("requestId", requestId) xmlmc.add_param("h_summary", "hornbill summary from SOMEWHERE has been updated") xmlmc.add_param("h_description", "Some Desc i have also been updated") json_string = xmlmc.invoke("apps/com.hornbill.servicemanager/Requests", "update") # Now Close The Ticket xmlmc.add_param("requestId", requestId) xmlmc.add_param("closeText", "This Ticket had to go") json_string = xmlmc.invoke("apps/com.hornbill.servicemanager/Requests", "closeRequest") 1 Link to comment Share on other sites More sharing options...
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