Greetings,
I'm trying to consume an JSON API, but I need to pass some Headers along my GET
call.
My code is the following:
import httpclient, json
let client = newHttpClient()
client.headers = newHttpHeaders({ "Content-Type": "application/json" })
let body = %*{
"data": "some text"
}
var xheaders = ""
xheaders = xheaders & "x-mashape-proxy-secret:" & "asdfgqwert" & "\c\L"
xheaders = xheaders & "x-mashape-User:" & "poiuylkjhg" & "\c\L"
client.request("http://127.0.0.1:5000/region?country=xx&area-code=17",
httpMethod = HttpGet, extraHeaders = xheaders, body = $body)
However, I'm getting the error: myhttpclient.nim(20, 12) Error: type mismatch:
got (HttpClient, string, httpMethod: HttpMethod, extraHeaders: string, body:
string)
Something is wrong over here, but I'm stucked...
Thanks for any help.
Cheers