<?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 2.2.8 SDK differences from 1.0 - field format in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446608#M77677</link>
    <description>&lt;P&gt;We have a C# application, written many years ago, that uses SDK 1.0 to query Splunk and process the fields of interest in the results.  Basically, it was done executing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchMgr = new SearchManager(_SplunkConnection);
searchJob = searchMgr.SyncSearch(searchQuery, dispatchParams)
rawResults = searchJob.GetResultsRaw(resultParams).ToString()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the 'resultParams' specified a 'FieldList' of the specific result fields of interest.  All the following code had to do was to loop through the XML representation of the individual field names and their corresponding results.  I was hoping to find equivalent functionality in SDK 2.2.8, but the best I could find is: the following code executed after creating a 'Service' object and logging into Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SearchResultStream stream = await service.SearchOneShotAsync(searchQuery)
foreach (SearchResult anEvent in stream)
rawEventStr = anEvent.ToString()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This code will return the query results we are expecting, but in the format of a single very long string 'SearchResult(...)' where contents between the parentheses are basically of the form ': '.  This string can be many hundreds of characters long with dozens of field names, most of which I don't care about. (Note that the old code only returned the fields I care about!)  &lt;/P&gt;

&lt;P&gt;I can probably write C# code that will parse this, but there has to be a better way to do it using SDK 2.2.8 functionality but after a lot of searching I can find nothing.  Does anyone have a more elegant solution to this problem?  Any help would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Dec 2018 20:11:05 GMT</pubDate>
    <dc:creator>rgonzale6</dc:creator>
    <dc:date>2018-12-13T20:11:05Z</dc:date>
    <item>
      <title>2.2.8 SDK differences from 1.0 - field format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446608#M77677</link>
      <description>&lt;P&gt;We have a C# application, written many years ago, that uses SDK 1.0 to query Splunk and process the fields of interest in the results.  Basically, it was done executing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;searchMgr = new SearchManager(_SplunkConnection);
searchJob = searchMgr.SyncSearch(searchQuery, dispatchParams)
rawResults = searchJob.GetResultsRaw(resultParams).ToString()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the 'resultParams' specified a 'FieldList' of the specific result fields of interest.  All the following code had to do was to loop through the XML representation of the individual field names and their corresponding results.  I was hoping to find equivalent functionality in SDK 2.2.8, but the best I could find is: the following code executed after creating a 'Service' object and logging into Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SearchResultStream stream = await service.SearchOneShotAsync(searchQuery)
foreach (SearchResult anEvent in stream)
rawEventStr = anEvent.ToString()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This code will return the query results we are expecting, but in the format of a single very long string 'SearchResult(...)' where contents between the parentheses are basically of the form ': '.  This string can be many hundreds of characters long with dozens of field names, most of which I don't care about. (Note that the old code only returned the fields I care about!)  &lt;/P&gt;

&lt;P&gt;I can probably write C# code that will parse this, but there has to be a better way to do it using SDK 2.2.8 functionality but after a lot of searching I can find nothing.  Does anyone have a more elegant solution to this problem?  Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 20:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446608#M77677</guid>
      <dc:creator>rgonzale6</dc:creator>
      <dc:date>2018-12-13T20:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: 2.2.8 SDK differences from 1.0 - field format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446609#M77678</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can access the fields with the GetValue(fieldname) method&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        SearchResultStream stream = await service.SearchOneShotAsync("search index=main | head 10");

        foreach (SearchResult anEvent in stream)
        {
            foreach( var field in anEvent.FieldNames)
            {
                Console.WriteLine($"{field} = {anEvent.GetValue(field)}");
            }
        }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jan 2019 09:00:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446609#M77678</guid>
      <dc:creator>ewan000</dc:creator>
      <dc:date>2019-01-03T09:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: 2.2.8 SDK differences from 1.0 - field format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446610#M77679</link>
      <description>&lt;P&gt;Perfect! Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/2-2-8-SDK-differences-from-1-0-field-format/m-p/446610#M77679</guid>
      <dc:creator>rgonzale6</dc:creator>
      <dc:date>2019-01-09T19:36:42Z</dc:date>
    </item>
  </channel>
</rss>

