java 是否可以使用 Postman Chrome 扩展程序发送哈希图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36708859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:47:45  来源:igfitidea点击:

Is it possible to send an hashmap with the Postman Chrome extension?

javarestgoogle-chromehashmappostman

提问by Kiran

I've been using Postman Chrome extension to test out my API and would like to send an Hashmap via post. Is there a way to send something map as a parameter in Postman?

我一直在使用 Postman Chrome 扩展程序来测试我的 API,并想通过邮寄方式发送一个 Hashmap。有没有办法在 Postman 中发送一些地图作为参数?

 HashMap inputHM = new HashMap();

                        inputHM.put("MVMT", "VL");
                        inputHM.put("NO", 1);
                        inputHM.put("FE", "E");
                        inputHM.put("CT", "20");
                        inputHM.put("HT", "80");
                        inputHM.put("TYPE", "GP");
                        inputHM.put("OPR_CD", "MAEU");
                        inputHM.put("LOCATION", "BERT");
                        inputHM.put("TMNL", "1");
                        inputHM.put("INCL", "");
                        inputHM.put("ID", 1);

My Controller is as follows

我的控制器如下

@RequestMapping(value = "/getBest", method = RequestMethod.POST)
public @ResponseBody
JsonResponse getBest(@RequestBody HashMap hm) {

    JsonResponse json = new JsonResponse();
    json.setSuccessData(rdtRequestService.getBest(hm));
    return json;
}

回答by Hassingard

When you send the request through POSTMAN, select the type as POST, then select the "raw" option and then just send a JSON in the "body" with the values you want to put in your HashMap. Remember to select "application/json" . Hymanson will transform the JSON into a HashMap for you.

当您通过 POSTMAN 发送请求时,选择类型为 POST,然后选择“原始”选项,然后在“正文”中发送一个 JSON,其中包含要放入 HashMap 的值。记得选择 "application/json" 。Hymanson 将为您将 JSON 转换为 HashMap。

An example from a fragment from your code would be

来自您的代码片段的一个示例是

{
"NO": 1,
"FE": "E",
"CT": "20"

}

}

Hymanson will do the rest for you, I mean, mapping that JSON to your HashMap

Hymanson 会为您完成剩下的工作,我的意思是,将 JSON 映射到您的 HashMap

回答by asg

Please use the following payload in the POSTMAN for a POST method. Please take a look at this post.

请在 POSTMAN 中使用以下有效负载作为 POST 方法。请看看这篇文章

{
    "LOCATION": "BERT",
    "TMNL": "1",
    "NO": 1,
    "CT": "20",
    "OPR_CD": "MAEU",
    "MVMT": "VL",
    "ID": 1,
    "HT": "80",
    "INCL": "",
    "TYPE": "GP",
    "FE": "E"
}