In this article, we will review the procedure for retrieving Sitecore Search results using Postman.
![](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F68ux8NRmGZBVGGy87XBohw%2F41c555a37e4b4e3eb2c5327dcfc8ec0c%2Fferenc-almasi-HfFoo4d061A-unsplash.jpg&w=3840&q=75)
We have previously shown you how to execute a query using the developer resources.
Postman can be used to identify generic data acquisition methods.
Create Query
Open the developer's resource that we have previously introduced, and first get a query to sample. This time, to get the simplest results, we will set up the following
![postmansearch01.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F2IXSXNDtdG8fx80IRbuAWY%2F2171149c9900437509ed263aa2040f6a%2Fpostmansearch01.png&w=3840&q=75)
When actually executed, the Response screen on the right side returns Json data. This time, we will check how to access the data from this query. In fact, if you click the clipboard button just to the left of Run, a menu will appear as shown below.
![postmansearch02.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F7KHzCysYBxNacLzrww1t2j%2F9165c4cb027aa80cea3a0a5f0f72b979%2Fpostmansearch02.png&w=3840&q=75)
This time select Copy as cURL uing Sitecore Host for the first item in the menu. If you have a subdomain available, the second menu item is also fine. To execute the obtained command, we will use the Ubuntu command line provided by WSL. Note that we have added > result.json after the acquired command in order to save the output data in a text file.
![postmansearch03.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F3z3HBm0iDkRuOvP6xBs4IJ%2Fd23473b2d66664edf7f4d6f54460b2de%2Fpostmansearch03.png&w=3840&q=75)
You can see that you got the result, or you can run code result.json and Visual Studio Code returns the Json data.
![postmansearch04.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2FCDB25lYHDrHnUkDwoG3Ox%2Fbc6be96243f4ac01615ba3b96729302b%2Fpostmansearch04.png&w=3840&q=75)
The goal of this project is to see if the same behavior as above can be obtained with Postman.
Running a query in Postman
When actually retrieving data with Postman, the key point is to access the data by setting the data in the header and body as in the above cURL execution.
First, configure Postman by passing the URL of the command that actually worked to Post.
![postmansearch05.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F5opiIHfc6p2r5fK4gQvK9C%2F1ef15cca7d5463647feea66926de80d0%2Fpostmansearch05.png&w=1920&q=75)
The command line includes several items to be passed as Header, but this time only application/json is set as content-type.
Finally, as for the query to pass data, it is a form of Query for the body, which can be easily set by clicking on the third item in the Developer Resources clipboard, Copy as data object, to get it. The query is written in the form of a Query for the body.
![postmansearch06.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F6P0VweSBJ5GUNXdSMVl46I%2F2a257d5357194fb348ffabb879bab80d%2Fpostmansearch06.png&w=1920&q=75)
When executed, the data could be retrieved as follows.
![postmansearch07.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F2VKMxhuPXPL8nCjJxM55e4%2Fc478d2788b65ddd1e19591afbd78e897%2Fpostmansearch07.png&w=1920&q=75)
Change the query
From the Developer Resource screen, a query is created using builder, and how to write this query is introduced in the following page.
The query can be created by referring to Payload on the right side of this screen. For example, the following is for the standard data listed.
"widget": {
"items": [
{
"entity": "content",
"rfk_id": "rfkid_7",
"search": {
"content": {}
}
}
]
}
The result is not specified above, but if you go to Payload, you can select the fields as follows.
![postmansearch08.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F7EgQVtcd6ZhCCmyj9tBE00%2F47825eb7b9890353be5b5d83839a1dd3%2Fpostmansearch08.png&w=1920&q=75)
Also, for the sources you are crawling, you can use the ID to filter the results. For this, you will see that there is a "sources" item in Payload.
![postmansearch09.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F2cKMpflvNJDmRgC5dvuwX3%2F31234f49dc726c360ed216b168161b12%2Fpostmansearch09.png&w=1920&q=75)
As for the source, the ID is displayed in the source list, and the ID is used.
![postmansearch10.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F40zb01EIPDZMnxa54dBcL4%2Fae7f90eaaecb02fbfbbf7d436cafe7d4%2Fpostmansearch10.png&w=3840&q=75)
The resulting statement shall be as follows
"items": [
{
"entity": "content",
"rfk_id": "rfkid_7",
"search": {
"content": {
"fields": [
"url"
]
}
},
"sources": [
"source-id"
]
}
]
As shown below, we were able to obtain only the results we wanted.
![postmansearch11.png](/_next/image?url=https%3A%2F%2Fimages.ctfassets.net%2Fzi1ovlormku8%2F3BM5Eqk2BvsUHg0cNQhQV2%2Fa57df78b5421cc83ef25e7510dabdb05%2Fpostmansearch11.png&w=1920&q=75)
Summary
The results retrieved by Sitecore Search have been narrowed down to only the data that we want to retrieve. This is another confirmation of how to retrieve data outside of the Widget that has already been implemented.