Michael Chav
Michael Chav

Reputation: 449

Send a GET request with headers in Haskell

I would like to send an HTTP GET request with an auth header and a custom header in Haskell. I can't seem to find a way to do it - most things seem only to care about headers in POST request. Can anyone help me? So in this case I'm trying to send:

Authorisation: AUTH_INFO_STRING
custom-header: string

To the URL: someUrl/query?[search_term]

Upvotes: 1

Views: 621

Answers (1)

sid-kap
sid-kap

Reputation: 1119

Using the Wreq library, I believe

let opts = defaults & header "Authorisation" .~ ["AUTH_INFO_STRING"] 
                    & header "custom-header" .~ ["string"] 
                    & param  "search_term"   .~ ["my","search"]
getWith opts "http://httpbin.org/someUrl"

should do what you want.

Upvotes: 4

Related Questions