<?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 API Authentification in Services Discussions</title>
    <link>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4649435#M911</link>
    <description>&lt;P&gt;I'm attempting to set up a connection to Stealthwatch via an SSIS c# script. The following fails on the last line with message "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." The curl command in the documentation has a "-K" option which might be the issue, but I don't know how that needs to be reflected in my json request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;string wUrl = "&lt;A href="https://stealthwatch.nas.hscn.nhs.uk/token/v2/authenticate" target="_blank" rel="noopener"&gt;https://stealthwatch.nas.hscn.nhs.uk/token/v2/authenticate&lt;/A&gt;";&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var httpRequest = (HttpWebRequest)WebRequest.Create(wUrl);&amp;nbsp;&lt;/P&gt;&lt;P&gt;httpRequest.Method = "POST";&lt;BR /&gt;httpRequest.ContentType = "application/json";&lt;BR /&gt;var data = "{\"username\":\"gsheehan\",\"password\":\"****\"}";&lt;/P&gt;&lt;P&gt;using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))&lt;BR /&gt;{&lt;BR /&gt;streamWriter.Write(data);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var httpResponse = (HttpWebResponse)httpRequest.GetResponse();&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2022 10:41:14 GMT</pubDate>
    <dc:creator>gerry.sheehan1</dc:creator>
    <dc:date>2022-07-13T10:41:14Z</dc:date>
    <item>
      <title>API Authentification</title>
      <link>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4649435#M911</link>
      <description>&lt;P&gt;I'm attempting to set up a connection to Stealthwatch via an SSIS c# script. The following fails on the last line with message "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." The curl command in the documentation has a "-K" option which might be the issue, but I don't know how that needs to be reflected in my json request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;string wUrl = "&lt;A href="https://stealthwatch.nas.hscn.nhs.uk/token/v2/authenticate" target="_blank" rel="noopener"&gt;https://stealthwatch.nas.hscn.nhs.uk/token/v2/authenticate&lt;/A&gt;";&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var httpRequest = (HttpWebRequest)WebRequest.Create(wUrl);&amp;nbsp;&lt;/P&gt;&lt;P&gt;httpRequest.Method = "POST";&lt;BR /&gt;httpRequest.ContentType = "application/json";&lt;BR /&gt;var data = "{\"username\":\"gsheehan\",\"password\":\"****\"}";&lt;/P&gt;&lt;P&gt;using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))&lt;BR /&gt;{&lt;BR /&gt;streamWriter.Write(data);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var httpResponse = (HttpWebResponse)httpRequest.GetResponse();&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 10:41:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4649435#M911</guid>
      <dc:creator>gerry.sheehan1</dc:creator>
      <dc:date>2022-07-13T10:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: API Authentification</title>
      <link>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4649565#M912</link>
      <description>&lt;P&gt;You need to bypass the certificate check (or ignore any ssl related errors). not too sure about C# but according to google this should work:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;string wUrl = "https://stealthwatch.nas.hscn.nhs.uk/token/v2/authenticate";  
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };   
var httpRequest = (HttpWebRequest)WebRequest.Create(wUrl); 

httpRequest.Method = "POST";
httpRequest.ContentType = "application/json";
var data = "{\"username\":\"gsheehan\",\"password\":\"****\"}";

using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
streamWriter.Write(data);
}

var httpResponse = (HttpWebResponse)httpRequest.GetResponse();&lt;/LI-CODE&gt;
&lt;P&gt;HTH&lt;BR /&gt;Marcel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 14:18:20 GMT</pubDate>
      <guid>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4649565#M912</guid>
      <dc:creator>Marcel Zehnder</dc:creator>
      <dc:date>2022-07-13T14:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: API Authentification</title>
      <link>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4655420#M914</link>
      <description>&lt;P&gt;Thanks Marcel. It made a difference, in that I receive a different error now : "The remote server returned an error: (415) Unsupported Media Type."&lt;/P&gt;&lt;P&gt;I added extra code:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;httpRequest.MediaType = "application/json";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; httpRequest.Accept = "application/json";&lt;/P&gt;&lt;P&gt;but it hasn't made any difference.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 11:35:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4655420#M914</guid>
      <dc:creator>gerry.sheehan1</dc:creator>
      <dc:date>2022-07-22T11:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: API Authentification</title>
      <link>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4655575#M915</link>
      <description>&lt;P&gt;Looks like I had an issue with how I passed in the credentials. The following worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Build Username/password in to POST data&lt;BR /&gt;var postData = "username=" + Uri.EscapeDataString(username);&lt;BR /&gt;postData += "&amp;amp;password=" + Uri.EscapeDataString(password);&lt;BR /&gt;var data = Encoding.ASCII.GetBytes(postData);&lt;/P&gt;&lt;P&gt;httpRequest.Method = "POST";&lt;BR /&gt;httpRequest.ContentType = "application/x-www-form-urlencoded";&lt;BR /&gt;httpRequest.ContentLength = data.Length;&lt;BR /&gt;using (var streamWriter = httpRequest.GetRequestStream())&lt;BR /&gt;{&lt;BR /&gt;streamWriter.Write(data, 0, data.Length);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help was much appreciated. I'll close the case&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 15:42:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/services-discussions/api-authentification/m-p/4655575#M915</guid>
      <dc:creator>gerry.sheehan1</dc:creator>
      <dc:date>2022-07-22T15:42:43Z</dc:date>
    </item>
  </channel>
</rss>

