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))


On Friday, May 15, 2020 at 3:57:52 PM UTC-4, je back wrote:
>
> I'm having trouble with formatting the #:data parameter to a http-sendrecv 
> request.  If I insert the string literal after #:data "my string" it works, 
> if I bind the string to a symbol (define my-string "my string") and call 
> with #:data my-string i get an error from the severs: HTTP/1.1 400 Bad 
> Request .  Is there a way to echo or examine the request as sent? 
>
> Also, I can't figure out where the source code for this library is located.
>
> Thanks,
> Jan Erik
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/71ab7c4d-cd3a-49ea-94a4-82f8316465e3%40googlegroups.com.

Reply via email to