Json file is not recognized by postman in data

Hi,

if i select a json file in a collection/Runner in Data
it returns: error when parsing file.
What i wrong with the json file?

The content of the file is:

{
“data”: [

    {
       file1: "file.txt",
       file2: "file2.txt"
     },
     {
       file1: "file3.txt",
       file2: "file4.txt"
     }

]
}

It needs to be an array so a structure like this:

[
   {
        "userId": 1
   }, 
   {
        "userId": 2
   } 
] 

More information can be found here:

Hi @danny-dainton ,

when importing json file it returns error if it contains:

[
{
"file1": "c:\temp\file.txt",
"file2": "c:\temp\file2.txt"
}
]

It accepts if json contains:

[
{
"file1": "file.txt",
"file2": "file2.txt"
}
]

I need to put the path for the file.

i found more explanation here:

To use that, you need to escape the \ characters:

[
	{
		"file1": "c:\\temp\\file.txt",
		"file2": "c:\\temp\\file2.txt"
	}
]

Yes i tried but it send the path with \
Postman can’t find the file with \ nor // or /

That’s just a string value its not the same as you selecting form-data and then specifying a file location on your system.

yes i see it’s just a string and different from selecting form-data specifying a file location.
Here when i preview the json file after importing, it already shows with \ and in the request body the path comes with double \ then it returns error because it cannot find the file.

You might need to add example images of the things you can see, to bring the information to life :grin:

1 Like