<?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 Exception returned from Splunk when running simple search query via the splunk java sdk in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Exception-returned-from-Splunk-when-running-simple-search-query/m-p/75483#M1050</link>
    <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I am running one of the simple search examples provided in the splunk Java SDK distribution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    public class Program {

public static void main(String[] args) {
    try {
        run(args);
    }
    catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

static void run(String[] args) throws IOException {
    Command command = Command.splunk("search");
    command.parse(args);

    if (command.args.length != 1)
        Command.error("Search expression required");
    String query = command.args[0];

    Service service = Service.connect(command.opts);

    // Check the syntax of the query.
    try {
        Args parseArgs = new Args("parse_only", true);
        service.parse(query, parseArgs);
    }
    catch (HttpException e) {
        String detail = e.getDetail();
        Command.error("query '%s' is invalid: %s", query, detail);
    }

    // This is the simplest form of searching splunk. Note that additional
    // arguments are allowed, but they are not shown in this example.
    InputStream stream = service.oneshotSearch(query);

    InputStreamReader reader = new InputStreamReader(stream, "UTF8");
    try {
        OutputStreamWriter writer = new OutputStreamWriter(System.out);
        try {
            int size = 1024;
            char[] buffer = new char[size];
            while (true) {
                int count = reader.read(buffer);
                if (count == -1) break;
                writer.write(buffer, 0, count);
            }

            writer.write("\n");
        }
        finally {
            writer.close();
        }
    }
    finally {
        reader.close();
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;When running the example from the command line as follows: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java com.splunk.examples.search_simple.Program "search * |  head 10" --host=my_splunk_instance --port=80 --scheme=http
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;..I keep getting the following exception:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    [Fatal Error] :1:50: White spaces are required between publicId and systemId.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;com.splunk.HttpException: HTTP 400&lt;BR /&gt;
        at com.splunk.HttpException.create(HttpException.java:59)&lt;BR /&gt;
        at com.splunk.HttpService.send(HttpService.java:355)&lt;BR /&gt;
        at com.splunk.Service.send(Service.java:1203)&lt;BR /&gt;
        at com.splunk.HttpService.post(HttpService.java:212)&lt;BR /&gt;
        at com.splunk.Service.oneshotSearch(Service.java:1094)&lt;BR /&gt;
        at com.splunk.Service.oneshotSearch(Service.java:1115)&lt;BR /&gt;
        at com.splunk.examples.search_simple.Program.run(Program.java:70)&lt;BR /&gt;
        at com.splunk.examples.search_simple.Program.main(Program.java:34)&lt;/P&gt;

&lt;P&gt;It appears as if the server is expecting the request in XML or JSON format. Any help much appreciated&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Joe&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 14:51:28 GMT</pubDate>
    <dc:creator>josephotoole</dc:creator>
    <dc:date>2020-09-28T14:51:28Z</dc:date>
    <item>
      <title>Exception returned from Splunk when running simple search query via the splunk java sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Exception-returned-from-Splunk-when-running-simple-search-query/m-p/75483#M1050</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I am running one of the simple search examples provided in the splunk Java SDK distribution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    public class Program {

public static void main(String[] args) {
    try {
        run(args);
    }
    catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

static void run(String[] args) throws IOException {
    Command command = Command.splunk("search");
    command.parse(args);

    if (command.args.length != 1)
        Command.error("Search expression required");
    String query = command.args[0];

    Service service = Service.connect(command.opts);

    // Check the syntax of the query.
    try {
        Args parseArgs = new Args("parse_only", true);
        service.parse(query, parseArgs);
    }
    catch (HttpException e) {
        String detail = e.getDetail();
        Command.error("query '%s' is invalid: %s", query, detail);
    }

    // This is the simplest form of searching splunk. Note that additional
    // arguments are allowed, but they are not shown in this example.
    InputStream stream = service.oneshotSearch(query);

    InputStreamReader reader = new InputStreamReader(stream, "UTF8");
    try {
        OutputStreamWriter writer = new OutputStreamWriter(System.out);
        try {
            int size = 1024;
            char[] buffer = new char[size];
            while (true) {
                int count = reader.read(buffer);
                if (count == -1) break;
                writer.write(buffer, 0, count);
            }

            writer.write("\n");
        }
        finally {
            writer.close();
        }
    }
    finally {
        reader.close();
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;When running the example from the command line as follows: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java com.splunk.examples.search_simple.Program "search * |  head 10" --host=my_splunk_instance --port=80 --scheme=http
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;..I keep getting the following exception:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    [Fatal Error] :1:50: White spaces are required between publicId and systemId.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;com.splunk.HttpException: HTTP 400&lt;BR /&gt;
        at com.splunk.HttpException.create(HttpException.java:59)&lt;BR /&gt;
        at com.splunk.HttpService.send(HttpService.java:355)&lt;BR /&gt;
        at com.splunk.Service.send(Service.java:1203)&lt;BR /&gt;
        at com.splunk.HttpService.post(HttpService.java:212)&lt;BR /&gt;
        at com.splunk.Service.oneshotSearch(Service.java:1094)&lt;BR /&gt;
        at com.splunk.Service.oneshotSearch(Service.java:1115)&lt;BR /&gt;
        at com.splunk.examples.search_simple.Program.run(Program.java:70)&lt;BR /&gt;
        at com.splunk.examples.search_simple.Program.main(Program.java:34)&lt;/P&gt;

&lt;P&gt;It appears as if the server is expecting the request in XML or JSON format. Any help much appreciated&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Joe&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Exception-returned-from-Splunk-when-running-simple-search-query/m-p/75483#M1050</guid>
      <dc:creator>josephotoole</dc:creator>
      <dc:date>2020-09-28T14:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Exception returned from Splunk when running simple search query via the splunk java sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Exception-returned-from-Splunk-when-running-simple-search-query/m-p/75484#M1051</link>
      <description>&lt;P&gt;Your command looks wrong, try this , replace with your actual enviornment values :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java com.splunk.examples.search_simple.Program "search * |  head 10" --host=somehost --port=8089 --scheme=https --username=admin --password=somepass
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2013 22:19:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Exception-returned-from-Splunk-when-running-simple-search-query/m-p/75484#M1051</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-09-27T22:19:27Z</dc:date>
    </item>
  </channel>
</rss>

