0

I'm trying to send the following data as multipart/form-data using postman, where the backend is not able to get the "details" array and it's nested parts

{
    "name": "any",
    "status": "ACTIVE",
    "slug": "any",
    "member_id": 1,
    "details": {
        "available_countries": {
            "US",
            "CA"
        },
        "available_languages": {
            "en_CA",
            "fr_CA"
        },
        "default_language": "en_CA",
        "prefix": "prefix",
        "time_zone": "EST"
    },
    "enabled" : true,
    "xml" : " <?xml version='1.0' encoding='UTF-8'?> <note> <to>test</to> <from>test</from><heading>test</heading><body>test</body></note> "
}

1 Answer 1

3

Here is how you can send nested arrays through form data

Input:

string:simple text
array[]:X
array[]:Y
array[]:Z
nested_array[available_countries][]:US
nested_array[available_countries][]:CA
nested_array[available_languages][]:EN
nested_array[available_languages][]:FR

Results:

{
    "string": "simple text",
    "array": [
        "X",
        "Y",
        "Z"
    ],
    "nested_array": {
        "available_countries": [
            "US",
            "CA"
        ],
        "available_languages": [
            "EN",
            "FR"
        ]
    }
}

Alternative Solution:

You can also convert your data to a JSON string, and then parse it in your backend

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.