Hi I have a desperate need where I want to read data from Elastic Search and the Get request is like
GET open_minor_alarms/events/_search
{
“query”:
“match”:{
"alarmOrigin": "Google"
}
}
}
Can we achieve this in Katalon
Hi I have a desperate need where I want to read data from Elastic Search and the Get request is like
GET open_minor_alarms/events/_search
{
“query”:
“match”:{
"alarmOrigin": "Google"
}
}
}
Can we achieve this in Katalon
Yes.
But you need to make a POST request and put the query into the body to use it in that form.
If you really have to do it with GET, you have to pass the query as a parameter to the call, e.g:
GET open_minor_alarms/events/_search?q=alarmOrigin:Google
see: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html
hi @ibus, i understand this thing " GET open_minor_alarms/events/_search?q=alarmOrigin:Google " but where exactly in katalon i have to use the above GET thing …pls help me,thanks in advance
In katalon , i have to use the above GET request in web UI testing category or API testing category? , pls help me , i am not understanding as i am new to katalon and elasticsearch
@Ibus your example request “GET open_minor_alarms/events/_search?q=alarmOrigin:Google” doesnt have any url,how does katalon come to know from which elasticsearch it should read data based on the query present in GET request, pls help me with this
and is this GET request correct? - “http://localhost:5601/app/kibana/ecommerce/product/_search?q=name:elasticsearch”
@Abdul_Shariff is that “open_minor” in your GET request your index name …pls help me how did u read data from elasticsearch…thanks in advance
Ue the Rest Request feature:
https://docs.katalon.com/katalon-studio/docs/restful.html
https://docs.katalon.com/katalon-studio/videos/katalon-api-introduction.html
because i don’t know the url for your ES just append it to the right one
No, that is the kibana url. ElasticSearch default ports are 9200 and 9300.
so, if your ES is hosted locally, should be something like:
hi,@ibus thank you so much , it worked for me , but when i use this request as object in testcase and run the testcase , i am not able to print the response which is stored in variable , the webservice keyword i used is “send request” , pls help me , thanks in advance
Hi Revanth,
Try this
public ResponseObject initializePostRequest(){
/*Create your URL here*/
ResponseObject response = buildPostApi_Customised()
return response
}
String requestMethod = "POST"
TestObjectProperty header2 = new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/json")
TestObjectProperty header3 = new TestObjectProperty("Accept", ConditionType.EQUALS, "application/json")
ArrayList defaultHeaders = Arrays.asList(header2, header3)
@Keyword
public ResponseObject buildPostApi_Customised() {
RequestObject ro = new RestRequestObjectBuilder()
.withRestUrl(/*YOURURL*/)
.withHttpHeaders(defaultHeaders)
.withRestRequestMethod(requestMethod)
.build()
ResponseObject respObj = WS.sendRequest(ro)
return respObj
}
To read the response refer to the documentation
https://docs.katalon.com/katalon-studio/tutorials/parse_json_responses.html#a-json-response-example
URL example : http://x.x.x.x:9200/open_critical_alarms/_search
To build your URL refer to the Curl command
curl -XGET “http://x.x.x.x:port/indexname/endpoint”