Sam: Thanks for the link to the source
Jon: I didn't include an example in my original post because the call is for obtaining an authorization token from a private server which made it awkward to share. But, thanks to your example, I pursued coming up with a good example and managed to get my original snippet working. I've pasted the example with the test server I used below. I found this server (
httpbin.org) helpful because it echos the data element that it received -- this enabled me to sort out my typos...
Jan Erik
#lang racket
(require net/http-client json)
(let* ((user "test_user")
(password "test_password")
(ht (hasheq 'client_id "test_client" 'grant_type "Bearer" 'username user 'password password)))
(define-values (status headers in)
(http-sendrecv "
httpbin.org"
"/post"
#:ssl? #t
#:version "1.1"
#:method "POST"
#:data (jsexpr->string ht)
#:headers (list "Content-Type: application/json")))
(displayln status)
(displayln headers)
(displayln (port->string in))
(close-input-port in))