<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342313#M41319</link>
    <description>&lt;P&gt;Well done &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Also, FYI , our company provide formal commercial support for our offerings , &lt;A href="http://www.baboonbones.com"&gt;www.baboonbones.com&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Apr 2018 07:22:42 GMT</pubDate>
    <dc:creator>Damien_Dallimor</dc:creator>
    <dc:date>2018-04-20T07:22:42Z</dc:date>
    <item>
      <title>Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342305#M41311</link>
      <description>&lt;P&gt;Getting below error for custom Authentication:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 04-19-2018 14:10:40.506 +0200 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" Exception performing request: 'token'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Input:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4783iE78C5D341632FBB8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Authhandlers.py:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;from requests.auth import AuthBase
import hmac
import base64
import hashlib
import urlparse
import urllib
import requests,json
#add your custom auth handler class to this module
class SessionKeyAuth(AuthBase):
        def __init__(self,**args):
                self.auth_url = args['auth_url']
                pass

        def __call__(self, r):
                if not 'X-HP3PAR-WSAPI-SessionKey' in r.headers:
                #perform auth
                        credentials = {'user':'xxxxx','password':'xxxxxx'}
                        req_args = {"verify" : False}
                        headers = {'content-type': 'application/json'}
                        auth_response = requests.post(self.auth_url,data=json.dumps(credentials),headers=headers,**req_args)
                        response_json = json.loads(auth_response.text)
                        session_key = response_json["key"]
                        r.headers['X-HP3PAR-WSAPI-SessionKey'] = session_key
                        return r

class TokenKeyAuth(AuthBase):
        def __init__(self,**args):
                self.auth_url = args['auth_url']
                pass

        def __call__(self, r):
                if not 'Authorization' in r.headers:
                #perform auth
                        credentials = {'username':'xxxxx','password':'xxxxxx'}
                        req_args = {"verify" : False}
                        headers = {'content-type': 'application/json'}
                        auth_response = requests.post(self.auth_url,data=json.dumps(credentials),headers=headers,**req_args)
                        response_json = json.loads(auth_response.text)
                        token_key = response_json["token"]
                        r.headers['Authorization'] = "Bearer "+token_key
                        return r
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Class SessionKeyAuth is for 3PAR storage and Class TokenKeyAuth is for HP uCMDB&lt;/P&gt;

&lt;P&gt;HP uCMDB REST API :&lt;/P&gt;

&lt;P&gt;&lt;A href="http://cmshelpcenter.saas.hp.com/CMS/10.33/ucmdb-docs/docs/eng/doc_lib/Content/REST_API/REST_API_Query_CIs_step_by_stey.htm"&gt;http://cmshelpcenter.saas.hp.com/CMS/10.33/ucmdb-docs/docs/eng/doc_lib/Content/REST_API/REST_API_Query_CIs_step_by_stey.htm&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;HP 3PAR is working but not uCMDB REST API class. Please help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:19:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342305#M41311</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-19T12:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342306#M41312</link>
      <description>&lt;P&gt;@damien ,pelase help&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:35:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342306#M41312</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-19T12:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342307#M41313</link>
      <description>&lt;P&gt;add some logging to your script and it'll give you more visibility to the error. &lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342307#M41313</guid>
      <dc:creator>jangid</dc:creator>
      <dc:date>2018-04-19T12:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342308#M41314</link>
      <description>&lt;P&gt;I am new to python,can you help me with few lines?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:59:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342308#M41314</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-19T12:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342309#M41315</link>
      <description>&lt;P&gt;Nothing immediately comes to mind , are there any more log error lines after the example you showed ? &lt;BR /&gt;
Perhaps the auth POST failed and hence the "token" JSON key was not present in the response , and an error was thrown trying to access it.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 05:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342309#M41315</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2018-04-20T05:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342310#M41316</link>
      <description>&lt;P&gt;Thanks for your response. I am eagerly waiting for you.&lt;/P&gt;

&lt;P&gt;After restarting the splunk service now I am getting 401 unauthorized error.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;04-20-2018 07:25:08.155 +0200 ERROR ExecProcessor - message from "python /opt/splunk/etc/apps/rest_ta/bin/rest.py" HTTP Request error: 401 Client Error: Unauthorized
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I took the returned token and tried REST API call on SOAP UI, the returned token seems to be not working in SOAP UI as well.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"error": "The following error has occurred:  Token is invalid or was tampered with. Please consult logs for more details"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I try to get token using SOAP UI, that token is valid and working.&lt;/P&gt;

&lt;P&gt;Both token (one returned in splunk rest api python and SOAP UI) format seems to be same with 177 characters and starting letters are similar in nature.&lt;/P&gt;

&lt;P&gt;I think I need to check on HP uCMDB wsapi logs on why the token returned using the script is not working.&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 05:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342310#M41316</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-20T05:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342311#M41317</link>
      <description>&lt;P&gt;Issue Resolved:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class TokenKeyAuth(AuthBase):
        def __init__(self,**args):
                self.auth_url = args['auth_url']
                pass

        def __call__(self, r):
                if not 'Authorization' in r.headers:
                #perform auth
                        data = {'username':'xxxxx','password':'xxxxxxx','clientContext':'1'}
                        req_args = {"verify" : False}
                        headers = {'Content-Type': 'application/json'}
                        auth_response = requests.post(self.auth_url,data=json.dumps(data),headers=headers,**req_args)
                        response_json = json.loads(auth_response.text)
                        token_key = response_json["token"]
                        r.headers['Authorization'] = "Bearer "+token_key
                        return r
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;'clientContext':'1' should be included in the message body. And a splunk service restart is required since the script checks header "Authorization" and uses the old token to communicate.&lt;/P&gt;

&lt;P&gt;The funny part is ,it returns token even if it is not included with content context but unusable.&lt;/P&gt;

&lt;P&gt;And thanks @damien for the mental support &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; . Atleast I have a person to discuss about Splunk REST API.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 07:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342311#M41317</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-20T07:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342312#M41318</link>
      <description>&lt;P&gt;I know nothing about uCMDB sorry.&lt;BR /&gt;
Perhaps trying tracing the requests on the network (wireshark etc..) and comparing what soapui sends vs what the rest mod input sends ie: compare the auth headers.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 07:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342312#M41318</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2018-04-20T07:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342313#M41319</link>
      <description>&lt;P&gt;Well done &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Also, FYI , our company provide formal commercial support for our offerings , &lt;A href="http://www.baboonbones.com"&gt;www.baboonbones.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 07:22:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342313#M41319</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2018-04-20T07:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Rest API to uCMDB is throwing error in REST API Modular Input?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342314#M41320</link>
      <description>&lt;P&gt;I knew this and I am following your answers silently &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 07:41:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-Rest-API-to-uCMDB-is-throwing-error-in-REST-API/m-p/342314#M41320</guid>
      <dc:creator>ansif</dc:creator>
      <dc:date>2018-04-20T07:41:02Z</dc:date>
    </item>
  </channel>
</rss>

