Downloading a JSON file after hitting soap UI https request
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020
09:13 AM
11-24-2020
09:13 AM
Downloading a JSON file after hitting soap UI https request
have one requirement to automate in SOAP UI Open source
Where I need to hit a https url and after hitting the url I need to download a json file for further use
I am able to login and browse the file location by using Basic Authorization.
In response, I can see the files name in html format.But further I wanted to download the file in local machine or to see a content of the file in the soap UI response so that assertions can be added.
Please suggest if there is any other approach in soap UI where we can download a file or see a content of file after hitting the https URL.
Where I need to hit a https url and after hitting the url I need to download a json file for further use
I am able to login and browse the file location by using Basic Authorization.
In response, I can see the files name in html format.But further I wanted to download the file in local machine or to see a content of the file in the soap UI response so that assertions can be added.
Please suggest if there is any other approach in soap UI where we can download a file or see a content of file after hitting the https URL.
11 REPLIES 11
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020
06:47 AM
12-02-2020
06:47 AM
Hi @sparrowenclave,
Here is a sample script to browse a directory containing json files and open each to find a specific node.
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import static java.util.stream.Collectors.toList;
File newFile;
String FolderPath = "<insert your path here>";
File selectedDirectory = new File(FolderPath);
List<Path> paths = new ArrayList<>();
try {
paths = Files.walk(Paths.get(new File(selectedDirectory.getPath())
.getAbsolutePath()))
.filter(p -> p.toFile().isFile())
.collect(toList());
} catch (IOException e) {
e.printStackTrace();
}
for (Path path : paths) {
newFile = new File(path.toString());
ObjectMapper mapperFileSource = new ObjectMapper();
JsonNode rootNode = null;
try {
rootNode = mapperFileSource.readTree(newFile);
} catch (IOException e) {
e.printStackTrace();
}
JsonNode searchNode = rootNode.findValue("<insert a node name here>");
if (searchNode != null) {
log.info(searchNode.textValue());
// You can add assertions here
}
}
It is just an example of what can be done.
Keep in min you'll need jackson's library.
Hope this will help.
David.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2020
09:44 AM
12-02-2020
09:44 AM
@ZDGN,
This is great...people ask for this every so often and now there's a definite way of doing it. I'll be saving this for when this pops up in my work, so nice one!
Rich
This is great...people ask for this every so often and now there's a definite way of doing it. I'll be saving this for when this pops up in my work, so nice one!
Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »