如何为 Elm post 请求指定主体媒体类型?

How to specify body media type for Elm post request?

我正在尝试使用 Elm 发出 post 请求,结果我的服务器输出了以下 'Unsupported Media Type' 错误。

POST /users/1/badges
  Request Body: M09991
  Accept: */*
  Status: 415 Unsupported Media Type 0.003431047s

我的 (servant) server is set to use PlainText 接收正文,我想知道我是否在 Elm 中正确指定了此内容类型。我在 Elm 中的 post 请求代码如下。

postUserBadge : ServerConfig.AdminContext -> Int -> String -> Cmd Msg
postUserBadge context userId licenseNumber =
    Http.send PostUserBadge <|
        postRequest context.baseContext
                    ("/users/" ++ toString userId ++ "/badges")
                    (Http.stringBody "text/plain" licenseNumber)
                    decodeUserBadge

我使用 Http.stringBody "text/plain" 来指定请求正文的内容类型。我从wikipedia's Media type page得到的字符串"text/plain";我没有在 Elm 的文档中找到如何指定媒体类型。

这是在此 Elm post 请求中指定明文媒体类型的正确方法吗?我的代码中是否有其他错误导致此 Http 415 错误?

PlainText 的仆人文档表明您应该发送 text/plain;charset=utf-8 作为 MIME 类型而不是 text/plain