So I am trying to write a pocket api library in Nim. I have the following code which makes a POST request to the pocket servers with a consumer key but I keep getting a 400 error saying that the consumer key is missing.
import httpclient
var client = newHttpClient()
client.headers = newHttpHeaders({ "Content-Type": "application/x-www-form-urlencoded" })
var url = "https://getpocket.com/v3/oauth/request"
let body = {
"consumer_key": "xxxxx-xxxxxxxxxxxxxxxxxxxxx",
"redirect_uri": "http://example.com/"
}
let response = client.request(url, httpMethod = HttpPost, body = $body)
echo response.status, response.headers
here is my output
400 Bad Request{"date": @["Thu, 18 Apr 2019 09:33:54 GMT"], "x-frame-options": @["SAMEORIGIN"], "content-length": @["15"], "p3p": @["policyref=\"/w3c/p3p.xml\", CP=\"ALL CURa ADMa DEVa OUR IND UNI COM NAV INT STA PRE\""], "x-error": @["Missing consumer key."], "content-type": @["text/html; charset=UTF-8"], "x-error-code": @["138"], "x-source": @["Pocket"], "server": @["Apache"], "status": @["400 Bad Request"], "connection": @["keep-alive"], "cache-control": @["private"]}
The consumer key is correct. I made a request with it using Postman and got a 200 response.