<?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: Stealthwatch REST API Problem in Network Security</title>
    <link>https://community.cisco.com/t5/network-security/stealthwatch-rest-api-problem/m-p/3877104#M109</link>
    <description>&lt;P&gt;Hi there. My name is Kyle Winters, Technical Marketing Engineer for Stealthwatch Services and APIs. I am happy to help answer your question. First, may I ask what version of Stealthwatch you are running?&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2019 21:39:15 GMT</pubDate>
    <dc:creator>kywinter</dc:creator>
    <dc:date>2019-06-20T21:39:15Z</dc:date>
    <item>
      <title>Stealthwatch REST API Problem</title>
      <link>https://community.cisco.com/t5/network-security/stealthwatch-rest-api-problem/m-p/3870783#M108</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I need to run scripts using the REST API for adding hostgroups but I can't do that because it returns an HTTP 500 error when I run the python script.&lt;BR /&gt;The script is the following:&lt;/P&gt;&lt;P&gt;Questa e' la funzione che uso per il token di autenticazione e riesco tranquillamente a farlo.&lt;/P&gt;&lt;PRE&gt;def getAccessToken():
    '''Get REST API Token'''

    url = "https://" + SW_SMC_ADDRESS + "/token/v2/authenticate"

    print('Stealthwatch login URL: ' + url)

    login_credentials = {
        "username": SW_USERNAME,
        "password": SW_PASSWORD
    }

    try:
        response = API_SESSION.post(url, data=login_credentials, verify=False)

        if response.status_code == 200:
            print('Successfully Authenticated.')
            return response.text
        else:
            print('SMC Connection Failure - HTTP Return Code: {}\nResponse: {}'.format(response.status_code, response.text))
            exit()

    except Exception as err:
        print('Unable to post to the SMC - Error: {}'.format(err))
        exit()&lt;/PRE&gt;&lt;P&gt;Mentre questa e' la funzione che utso per fare l'aggiunta dell'hostgroup ma mi restituisce un errore HTTP 500:&lt;/P&gt;&lt;PRE&gt;def addHostGroup():

    url = 'https://{}/smc-configuration/rest/v1/tenants/{}/tags'.format(SW_SMC_ADDRESS, SW_DOMAIN_ID)

    hostg = {"name": "Test1","location": "INSIDE","description": "Test1","ranges": ["10.10.10.10/32"],"hostBaselines": "false","suppressExcludedServices": "true","inverseSuppression": "false","hostTrap": "false","sendToCta": "false","parentId": 1}

    try:
        response = API_SESSION.post(url, data=hostg, verify=False)

        if response.status_code == 200:
            print('Success')
            return response.text
        else:
            print('Failure - HTTP Return Code: {}\nResponse: {}'.format(response.status_code, response.text))
            exit()

    except Exception as err:
        print('Unable to post to the SMC - Error: {}'.format(err))
        exit()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that when I connect to the https: // &amp;lt;smc ip&amp;gt; /smc/restapi-docs/index.html page the error in the image is returned.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="swagger error.png" style="width: 999px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/38378i7DA29E1739C0B1E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="swagger error.png" alt="swagger error.png" /&gt;&lt;/span&gt;&lt;BR /&gt;how can i solve?&lt;BR /&gt;thank you&lt;BR /&gt;regards&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 09:13:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/stealthwatch-rest-api-problem/m-p/3870783#M108</guid>
      <dc:creator>fbarducci</dc:creator>
      <dc:date>2019-06-11T09:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stealthwatch REST API Problem</title>
      <link>https://community.cisco.com/t5/network-security/stealthwatch-rest-api-problem/m-p/3877104#M109</link>
      <description>&lt;P&gt;Hi there. My name is Kyle Winters, Technical Marketing Engineer for Stealthwatch Services and APIs. I am happy to help answer your question. First, may I ask what version of Stealthwatch you are running?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 21:39:15 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/stealthwatch-rest-api-problem/m-p/3877104#M109</guid>
      <dc:creator>kywinter</dc:creator>
      <dc:date>2019-06-20T21:39:15Z</dc:date>
    </item>
  </channel>
</rss>

