guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

http-request bearer token syntax for Twitter v2 api


From: Mortimer Cladwell
Subject: http-request bearer token syntax for Twitter v2 api
Date: Wed, 12 Oct 2022 06:30:51 -0400

Hi,
Has anyone successfully submitted a bearer token to Twitter v2 api using
http-request? What syntax did you use? Without success I have tried many
permutations/splellings/capitalizations of:

  (let* (
(uri  "https://api.twitter.com/2/tweets";)
(data "{\"text\":\"Hello world!\"}")
(my-token (string-append "bearer " "abcde....myaccesstoken"))
(my-headers `((Content-type . "application/json")(Authorization .
,my-token))  )
)
      (receive (response body)
         (http-request uri #:method 'POST #:body data #:headers my-headers)
(pretty-print response) (pretty-print (utf8->string body))))

the error body:

"{\"errors\":[{\"message\":\"Requests with bodies must have content-type of
application/json.\"}],\"title\":\"Invalid Request\",\"detail\":\"One or
more parameters to your request was invalid.\",\"type\":\"
https://api.twitter.com/2/problems/invalid-request\"}";

I am not sure the "Requests with bodies must have content-type of
application/json." is the real error. I think it is "Authorization: bearer
abcde....".  Can http-request handle a bearer token?

I know my tokens are valid because I can successfully submit them using
curl.
Thanks
Mortimer


reply via email to

[Prev in Thread] Current Thread [Next in Thread]