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/3439a89d-2a3b-497f-9258-58d3c858c2bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to