Hi,

I can't reproduce the problem you've described with Graylog 1.3.3:

$ curl -u admin:admin -i -H 'Accept: application/json' 
'http://localhost:12900/search/universal/absolute?query=*&from=2016-02-29T00:00:00.000Z&to=2016-03-01T00:00:00.000Z&fields=timstamp,source&limit=5&pretty=true'
HTTP/1.1 200 OK
Content-Type: application/json
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
X-Runtime-Microseconds: 10965
Transfer-Encoding: chunked

{
  "query" : "*",
  "built_query" : 
"{\"from\":0,\"size\":5,\"query\":{\"filtered\":{\"query\":{\"match_all\":{}},\"filter\":{\"bool\":{\"must\":{\"range\":{\"timestamp\":{\"from\":\"2016-02-29
 
00:00:00.000\",\"to\":\"2016-03-01 
00:00:00.000\",\"include_lower\":true,\"include_upper\":true}}}}}}},\"fields\":[\"timestamp\",\"source\"],\"sort\":[{\"timestamp\":{\"order\":\"desc\"}}]}",
  "used_indices" : [ ],
  "messages" : [ {
    "message" : {
      "source" : "example.org",
      "timestamp" : "2016-02-29T09:56:37.270Z"
    },
    "index" : "graylog2_7",
    "highlight_ranges" : null
  }, {
    "message" : {
      "source" : "example.com",
      "timestamp" : "2016-02-29T09:56:37.257Z"
    },
    "index" : "graylog2_7",
    "highlight_ranges" : null
  }, {
    "message" : {
      "source" : "example.net",
      "timestamp" : "2016-02-29T09:56:37.251Z"
    },
    "index" : "graylog2_7",
    "highlight_ranges" : null
  }, {
    "message" : {
      "source" : "example.wtf",
      "timestamp" : "2016-02-29T09:56:37.244Z"
    },
    "index" : "graylog2_7",
    "highlight_ranges" : null
  }, {
    "message" : {
      "source" : "example.org",
      "timestamp" : "2016-02-29T09:56:37.239Z"
    },
    "index" : "graylog2_7",
    "highlight_ranges" : null
  } ],
  "fields" : [ "source" ],
  "time" : 6,
  "total_results" : 29356,
  "from" : "2016-02-29T00:00:00.000Z",
  "to" : "2016-03-01T00:00:00.000Z"
}


Make sure that your HTTP requests are valid and that your Python HTTP 
client doesn't do strange things with accept headers.


Cheers,
Jochen


On Friday, 26 February 2016 16:44:03 UTC+1, packetsmacker wrote:
>
> Here is the function I am calling.
>
> glhost = 'http://server.com'
> glport = 12900
> restapi = '/search/universal/absolute'
> params = urllib.urlencode({
>     'query': searchstring,
>     'from': searchFrom,
>     'to': searchTo,
>     'fields': fields
>     })
>
> url="%s:%s%s?%s" % (glhost,glport,restapi,params) 
>
>
> request = urllib2.Request(url)
> username = 'fake'
> password = 'fake'
> base64string = base64.encodestring('%s:%s' % (username, 
> password)).replace('\n', '')
> request.add_header("Authorization", "Basic %s" % base64string)  
> request.add_header('Accept', 'application/json') 
> response = urllib2.urlopen(request)
> return response
>
>
>
> On Friday, February 26, 2016 at 6:21:32 AM UTC-5, Jochen Schalanda wrote:
>>
>> Hi,
>>
>> what's the exact request you're sending to the Graylog REST API?
>>
>> Cheers,
>> Jochen
>>
>> On Thursday, 25 February 2016 21:37:24 UTC+1, packetsmacker wrote:
>>>
>>> I am just now getting back to this :(
>>>
>>> Here is what I added but I still get back a csv.
>>>
>>> base64string = base64.encodestring('%s:%s' % (username, 
>>> password)).replace('\n', '')
>>> request.add_header("Authorization", "Basic %s" % base64string)  
>>> request.add_header('Accept', 'application/json') 
>>> response = urllib2.urlopen(request)
>>>
>>>
>>>
>>> On Friday, January 15, 2016 at 4:31:35 AM UTC-5, Jochen Schalanda wrote:
>>>>
>>>> Hi,
>>>>
>>>> simply provide an Accept header (i. e. Accept: application/json; see 
>>>> https://en.wikipedia.org/wiki/Content_negotiation) in your HTTP 
>>>> request to always get a response with the application/json content 
>>>> type.
>>>>
>>>>
>>>> Cheers,
>>>> Jochen
>>>>
>>>> On Wednesday, 13 January 2016 22:54:01 UTC+1, packetsmacker wrote:
>>>>>
>>>>> So I see two/search/universal/absolute methods (sorry I can't see to 
>>>>> recall the term at the moment) and the only difference I can see is one 
>>>>> requires fields and returns a csv the other returns json and doesn't 
>>>>> require feilds. Other then that I cant tell what is different. 
>>>>> <http://157.89.60.157:12900/api-browser#!/Search/Absolute/searchAbsoluteChunked_get_0>
>>>>>
>>>>> The problem I have is my get used to return json. Now when I run the 
>>>>> script it looks like it is failing because it is getting back a csv. So 
>>>>> when I went to look at the documentation I couldn't figure out how 
>>>>> graylog 
>>>>> would know which way I wanted it to return the data. I think it was 
>>>>> updated 
>>>>> since the last time I ran my script but I don't take care of that side of 
>>>>> the servers. How do I get it to return json? 
>>>>>
>>>>> <http://157.89.60.157:12900/api-browser#!/Search/Absolute/searchAbsoluteChunked_get_0>
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Graylog Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/graylog2/b1772a8a-8cf6-4289-acaf-93cd4162fa69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to