【问题标题】:How to send array request in body parameter retrofit android如何在body参数改造android中发送数组请求
【发布时间】:2022-01-15 00:31:49
【问题描述】:

这是我的请求,我需要在@Post 请求中发送 Data 作为键。请帮帮我,我被卡住了 2 天。

[
    {
        "barcodeList": "abc",
        "fieldboyId": "17",
        "lattitude": "37.4219513",
        "longitude": "-122.0841169",
        "quantity": "2",
        "refrenceId": "1",
        "sampleId": null,
        "sampleName": null,
        "sampleType": null,
        "type": "Barcode"
    },
    {
        "barcodeList": "acd",
        "fieldboyId": "17",
        "lattitude": "37.4219513",
        "longitude": "-122.0841169",
        "quantity": "1",
        "refrenceId": "1",
        "sampleId": null,
        "sampleName": null,
        "sampleType": null,
        "type": "Barcode"
    }
]

【问题讨论】:

  • 到目前为止您尝试过什么?你被困在哪里了?

标签: java android android-studio retrofit okhttp


【解决方案1】:

你可以制作这些课程:

public class RequestBody {
    List<Data> data;

    public class Data {
        String barcodeList;
        String fieldboyId;
        String lattitude;
        String longitude;
        String quantity;
        String refrenceId;
        String sampleId;
        String sampleName;
        String sampleType;
        String type;
    }
}

在界面中类似于

@POST("/api/path")
Call<Something> myPostRequest(@Body requestBody: RequestBody);

【讨论】:

  • 你能在java中帮忙吗???
  • 我很抱歉,抱歉,我错过了这不是一个 kotlin 问题。自从我用 Java 做以来已经有很长时间了。我会尝试编辑我的答案
  • 等待您的帮助。
猜你喜欢
  • 2013-09-25
  • 2019-10-05
  • 1970-01-01
  • 1970-01-01
  • 2020-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多