2

i am Posting a Map data as ArrayList. So i have tried it by Raw body. but i need to post it as Form-Data. I tried it by many ways but i didn't get result. if any one knows the solution, how to do it. please give me solution.

and here is my code belove.

    @Id
    private String id;

    @Field(value = "name")
    private String name;

    @Field(value = "description")
    private String description;

        @Field(value = "attributes")
        private List<Map<String, String>> attributes = new ArrayList<Map<String, String>>();

    this is what i am sending in Body Raw i want to post it by Form-Data

    {
        "name":"Fourth Template",
        "description":"covers most of selected attributes",
        "attributes": [
        {
          "attributeId": "5d4284807748181cbc8a8277",
          "selectedDataSource": "collections"
        },
         {
          "attributeId": "5d4284807748181cbc8a8277",
          "selectedDataSource": "paycom"
        },
         {
          "attributeId": "5d4284807748181cbc8a8277",
          "selectedDataSource": "originations"
        }
      ]
    }

2 Answers2

3

Instead of posting it as raw data, in postman you've form-data beside raw data, you can post your formData through it.

See the image link for your reference:

Posting a Map data as ArrayList

Meraj al Maksud
  • 1,528
  • 2
  • 22
  • 36
Zakir Hussain
  • 359
  • 2
  • 13
  • 1
    Hi I Thanks for your reply. i tried in your way but i am getting response in this way.{ "id": "5d42d6c6f139d532b88445fe", "name": "Fif", "description": "added most selected dataSources", "attributes": [ {}, {}, {} ] } } –  Aug 01 '19 at 12:14
  • 1
    its taking null map key and values –  Aug 01 '19 at 12:15
  • @ghaluprabha instead of using Form-data use **X-www-form-urluncoded**.. Hope that solves your problem. – Zakir Hussain Aug 02 '19 at 06:58
0

show your controller method, try add @RequestBody Entity or @RequestBody Map map.

  • Hi Thanks for your Reply. i used This format earlier using @RequestBody As Raw ,but i want to post it by form data, i didn't know the Form-data format in which format –  Aug 01 '19 at 11:53