I am using Akka Http 2.4.1 to send an https request to twitter api.
According to their documentation, I need two httpheaders. Namely: Authorization and ContentType.
To quote their documents:
The request should contain a Content-Type header with the value application / x-www-form-urlencoded; charset = UTF-8.
Here is my code:
val authorization = Authorization(BasicHttpCredentials(key, secret)) val contentType = RawHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8") Http().singleRequest( HttpRequest( uri = Uri("https://api.twitter.com/oauth2/token"), method = HttpMethods.POST, headers = List(authorization, contentType), entity = HttpEntity(`text/plain(UTF-8)`, "grant_type=client_credentials"), protocol = HttpProtocols.`HTTP/1.1`))
How to enable Content-Type header with value application/x-www-form-urlencoded;charset=UTF-8 using Akka-http 2.4.1?
source share