1

I'm trying to run the Postman collection runner with the following JSON file:

[
    {
        "articles": [
            {
                "created_date": "2019-04-09T12:00:00Z",
                "author_id": "4421-45V2-1909-2404-0143-J9936",
                "article_title": "the lord of the nameless",
                "article_content": "But I must explain to you how all this mistaken idea of denouncing...
            },
            {
                "created_date": "2022-03-01T01:00:00Z",
                "author_id": "090W-73W4-4407-3902-352P-193W9",
                "article_title": "avian shadow",
                "article_content": "The European languages are members of the same family...
            }
        ]
    }
]

However, each article in articles comes up as [object Object] in the request body:

enter image description here

It should be the array of articles, like this:

[
    {
        "created_date": "2019-04-09T12:00:00Z",
        "author_id": "4421-45V2-1909-2404-0143-J9936",
        "article_title": "the lord of the nameless",
        "article_content": "But I must explain to you how all this mistaken idea of denouncing...
     },
     {
        "created_date": "2022-03-01T01:00:00Z",
        "author_id": "090W-73W4-4407-3902-352P-193W9",
        "article_title": "avian shadow",
        "article_content": "The European languages are members of the same family...
     }
]

This is the body:

[{{articles}}]

And this is the pre-request script:

pm.globals.set("articles", JSON.stringify(pm.iterationData.toObject()));

Would appreciate help on how to fix this.

1 Answers1

0

try putting the class name before each object, like this:

[
    {
        "articles": [
            {
             "article":
                {
                    "created_date": "2019-04-09T12:00:00Z",
                    "author_id": "4421-45V2-1909-2404-0143-J9936",
                    "article_title": "the lord of the nameless",
                    "article_content": "But I must explain to you how all this 
                                  mistaken idea of denouncing...
                }
            },
            {
             "article":
                {
                    "created_date": "2022-03-01T01:00:00Z",
                    "author_id": "090W-73W4-4407-3902-352P-193W9",
                    "article_title": "avian shadow",
                    "article_content": "The European languages are members of 
                                 the same family...
                }
            }
        ]
    }
]