安卓改造 : content type as application/x-www-form-urlencoded

标签 android post retrofit

对 android 开发相当陌生。我正在尝试使用改造来发送发布请求。在我的改造日志中,我看到了

Content-Type: text/plain; charset=utf-8

我发现只有在我使用内容类型时请求才会起作用:

application/x-www-form-urlencoded

我搜索了谷歌并没有找到明确设置内容类型的明确方法。有人知道怎么做吗?

最佳答案

在您定义服务的类中,修改相关方法以遵循以下模式:

@FormUrlEncoded
@POST/GET/PUT/DELETE("/your_endpoint")
Object yourMethodName(@Field("your_field") String yourField,...);

关于安卓改造 : content type as application/x-www-form-urlencoded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28291006/

相关文章:

java - 在 Retrofit 中将表单数据发送到服务器

android - MVVM。如何将复杂的数据/命令从域传输到 View

android - 在 Android 中解析 Google Books JSON

java - 获取用户语言的所有星期天标签

Javascript POST 请求不起作用

php - 使用 Luracast ReSTLer——在正文中将 POST 变量作为 JSON 传递

Laravel 重定向为 POST

java - MVVM - 如何将上下文传递给存储库类?

android - 我怎样才能排除一个字段获得 Parcelabled?

Android Rest客户端给出内部服务器错误500的错误(使用改造的okhttp和gson)