Prachii
(Prachi)
April 27, 2020, 7:44am
1
I am using Postman for testing POST API. Purpose of API : The API should download some data at given “path”.
Case : 1 When I give hard-coded path in request body-
{
"downloadPath": "D:\\folderName",
"objectID": "1234"
}
I get expected response in this case.
Case : 2 I want to send this path and ID dynamically. Now the Request Body looks like-
{
"downloadPath": "{{path}}",
"objectID": "{{id}}"
}
It reads the values from JSON file which looks like-
[
{
"path":"D:\\folderName1",
"id":"1234"
},
{
"path":"D:\\folderName2",
"id":"5678"
}
]
It does not give expected response.
Note: Is it something related to backward slash present in the path? Because, when I give hard-coded path and then give only object ID dynamically through JSON file, it works.
What could be the reason?
Thanks in advance.
Hey @Prachii ,
Have you tried escaping those backslashes in the data file like this?
[
{
"path":"D:\\\\folderName1",
"id":"1234"
},
{
"path":"D:\\\\folderName2",
"id":"5678"
}
]
1 Like
Prachii
(Prachi)
April 27, 2020, 4:47pm
3
Hi @dannydainton ,
I tried 4 backslashes in the data file, but it gives only one at postman console and responds with the same error.
Postman console looks like
But I think this should not be an issue because, When I give file path manually in request body like
{
"downloadPath": "D:\\temp",
"objectID": "1234"
}
Then also it shows single slash in console request body
and still it works.
Did the actual request send the file that you wanted, from the Collection runner?
When I use the Collection Runner, I see this as the preview of the file:
This is what the request body looks like for that request:
What does the request look like for you, in this view? Ensure to select Save responses
before running the Collection.
I’m not sure why the Console Log output looks like that, I get the same thing, that might be a separate issue with the way that’s parsed, compared to what’s sent in the runner.
Prachii
(Prachi)
April 29, 2020, 4:32pm
6
Hi @danny-dainton ,
Actually solution with four backward slashes worked. I was making a spelling mistake while trying it at first. Really appreciate your efforts.
I will mark it as answered.
Thanks again!
1 Like
lkpe
(Lukas Petersen)
October 30, 2023, 3:21pm
7
Another solution is to replace backslash with “%5C”.
system
(system)
Closed
November 2, 2023, 3:21pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.