Java 安卓改型发布信息到api数据库
我如何在我的案例中发布来自android设备的信息到我的api路由。 目前,我的android显示器没有收到任何响应 我已经创建了一个基本的生成器类。 我创建了一个包含以下内容的ApiService:Java 安卓改型发布信息到api数据库,java,android,api,retrofit,Java,Android,Api,Retrofit,我如何在我的案例中发布来自android设备的信息到我的api路由。 目前,我的android显示器没有收到任何响应 我已经创建了一个基本的生成器类。 我创建了一个包含以下内容的ApiService: @FormUrlEncoded @POST("device") Call<DeviceResponse> device(@Field("device_name") String device_name, @Field("devic
@FormUrlEncoded
@POST("device")
Call<DeviceResponse> device(@Field("device_name") String device_name,
@Field("device_producer") String device_producer,
@Field("device_pixel_width") int device_pixel_width,
@Field("device_pixel_height") int device_pixel_height,
@Field("device_ratio_width") int device_ratio_width,
@Field("device_ratio_height") int device_ratio_height,
@Field("device_android_version") int device_android_version,
@Field("device_status") int device_status);
只需添加带有端点的
@POST
注释
@FormUrlEncoded
@POST("endPoint")
Call<DeviceResponse> device(@Field("device_name") String device_name,
@Field("device_producer") String device_producer,
@Field("device_pixel_width") int device_pixel_width,
@Field("device_pixel_height") int device_pixel_height,
@Field("device_ratio_width") int device_ratio_width,
@Field("device_ratio_height") int device_ratio_height,
@Field("device_android_version") int device_android_version,
@Field("device_status") int device_status);
@FormUrlEncoded
@POST(“端点”)
调用设备(@Field(“设备名称”)字符串设备名称,
@字段(“设备生成器”)字符串设备生成器,
@字段(“设备像素宽度”)int设备像素宽度,
@字段(“设备像素高度”)输入设备像素高度,
@字段(“设备比率宽度”)输入设备比率宽度,
@字段(“设备比率高度”)输入设备比率高度,
@字段(“设备安卓版本”)输入设备安卓版本,
@字段(“设备状态”)输入设备状态;
检查此项以了解更多信息:只需添加
@POST
注释和端点类似
@FormUrlEncoded
@POST("endPoint")
Call<DeviceResponse> device(@Field("device_name") String device_name,
@Field("device_producer") String device_producer,
@Field("device_pixel_width") int device_pixel_width,
@Field("device_pixel_height") int device_pixel_height,
@Field("device_ratio_width") int device_ratio_width,
@Field("device_ratio_height") int device_ratio_height,
@Field("device_android_version") int device_android_version,
@Field("device_status") int device_status);
@FormUrlEncoded
@POST(“端点”)
调用设备(@Field(“设备名称”)字符串设备名称,
@字段(“设备生成器”)字符串设备生成器,
@字段(“设备像素宽度”)int设备像素宽度,
@字段(“设备像素高度”)输入设备像素高度,
@字段(“设备比率宽度”)输入设备比率宽度,
@字段(“设备比率高度”)输入设备比率高度,
@字段(“设备安卓版本”)输入设备安卓版本,
@字段(“设备状态”)输入设备状态;
查看此项了解更多信息:尝试添加@POST,如下所示
@FormUrlEncoded
@POST("yourURLendpoint")
Call<DeviceResponse> device(@Field("device_name") String device_name,
@Field("device_producer") String device_producer,
@Field("device_pixel_width") int device_pixel_width,
@Field("device_pixel_height") int device_pixel_height,
@Field("device_ratio_width") int device_ratio_width,
@Field("device_ratio_height") int device_ratio_height,
@Field("device_android_version") int device_android_version,
@Field("device_status") int device_status);
@FormUrlEncoded
@POST(“您的URL端点”)
调用设备(@Field(“设备名称”)字符串设备名称,
@字段(“设备生成器”)字符串设备生成器,
@字段(“设备像素宽度”)int设备像素宽度,
@字段(“设备像素高度”)输入设备像素高度,
@字段(“设备比率宽度”)输入设备比率宽度,
@字段(“设备比率高度”)输入设备比率高度,
@字段(“设备安卓版本”)输入设备安卓版本,
@字段(“设备状态”)输入设备状态;
尝试像这样添加@POST
@FormUrlEncoded
@POST("yourURLendpoint")
Call<DeviceResponse> device(@Field("device_name") String device_name,
@Field("device_producer") String device_producer,
@Field("device_pixel_width") int device_pixel_width,
@Field("device_pixel_height") int device_pixel_height,
@Field("device_ratio_width") int device_ratio_width,
@Field("device_ratio_height") int device_ratio_height,
@Field("device_android_version") int device_android_version,
@Field("device_status") int device_status);
@FormUrlEncoded
@POST(“您的URL端点”)
调用设备(@Field(“设备名称”)字符串设备名称,
@字段(“设备生成器”)字符串设备生成器,
@字段(“设备像素宽度”)int设备像素宽度,
@字段(“设备像素高度”)输入设备像素高度,
@字段(“设备比率宽度”)输入设备比率宽度,
@字段(“设备比率高度”)输入设备比率高度,
@字段(“设备安卓版本”)输入设备安卓版本,
@字段(“设备状态”)输入设备状态;
如果我错了,很抱歉,但我是否有端点@POST(“设备”)
如果设备是您的端点,那么您应该在中添加@POST注释。对不起,我忘了复制它了,确定了吗?添加后仍然没有响应,或者您的意思是什么?@utdev请在firefox或chrome中的Postman中至少尝试一次API调用。如果我错了,但我是否有端点@POST(“设备”)
如果设备是您的端点,那么您应该在中添加@POST注释。对不起,我忘了复制它了。确定了吗?添加后仍然没有响应,或者您的意思是什么?@utdev请在firefox或chrome中的Postman中尝试您的API调用至少一次。。无论你有什么终点,在@Post annotationok中添加,仍然没有响应,或者你的意思是什么?我添加了这个@Post(“设备”)
,我忘了先粘贴它,也更新了问题代码没有用这种方式。。我的意思是说添加URL的端点,例如,如果它是add only/water\u layment/index.php/api/user/register,那么它应该是端点URL。我在我的构建器中定义了基本URL,如下所示:http://192.168.3.105/app/public/api/
设备的路由是http://192.168.3.105/app/public/api/device
ok。。无论你有什么终点,在@Post annotationok中添加,仍然没有响应,或者你的意思是什么?我添加了这个@Post(“设备”)
,我忘了先粘贴它,也更新了问题代码没有用这种方式。。我的意思是说添加URL的端点,例如,如果它是add only/water\u layment/index.php/api/user/register,那么它应该是端点URL。我在我的构建器中定义了基本URL,如下所示:http://192.168.3.105/app/public/api/
设备的路径为http://192.168.3.105/app/public/api/device