in older versions of Wiremock we could append te queryString to the matching url like this:
wireMockRule.stubFor(get(urlPathEqualTo("/rest/customer/find?custId=1&custId=2")) //
.willReturn(aResponse()) //
but now that we upgraded to recent versions we are bound to use withQueryParam method of the mapping builder - wiremock doesn't understand appended params anymore. But how do we achieve such behavior? I couldn't figure out how to inject the multi-value parameter in the stub.
Integer[] custIds = {1, 2};
wireMockRule.stubFor(get(urlPathEqualTo("/rest/customer/find")) //
.withQueryParam("userIds", equalTo(custIds.toString())) //
.willReturn(aResponse()) //
This doesn't work when we call the url with path "/rest/customer/find?custId=1&custId=2" from restTemplate.
You can try:
stubFor(get(urlEqualTo("/rest/user/list?userIds=5&userIds=6&userIds=7&userIds=8"))
or
stubFor(get(urlPathEqualTo("/rest/user/list"))
.withQueryParam("userIds", equalTo("5"))
.withQueryParam("userIds", equalTo("6"))
.withQueryParam("userIds", equalTo("7"))
.withQueryParam("userIds", equalTo("8"))
Trying to append the query params in the url results in this error:
2016-12-07 10:31:49.205 ERROR 1835 --- [qtp846274760-33] WireMock SFID= : Request was not matched:
{
"url" : "/rest/user/list?userIds=5&userIds=6&userIds=7&userIds=8",
"absoluteUrl" : "http://localhost:8889/rest/user/list?userIds=5&userIds=6&userIds=7&userIds=8",
"method" : "GET",
"clientIp" : "127.0.0.1",
"headers" : {
"User-Agent" : "Java/1.8.0_91",
"Connection" : "keep-alive",
"Host" : "localhost:8889",
"Accept" : "application/json, application/*+json"
},
"cookies" : { },
"browserProxyRequest" : false,
"loggedDate" : 1481113909179,
"bodyAsBase64" : "",
"body" : "",
"loggedDateString" : "2016-12-07T12:31:49Z"
}
Closest match:
{
"url" : "http://localhost:8889/rest/user/list?userIds=5&userIds=6&userIds=7&userIds=8",
"method" : "GET"
}
Related
How can I get kibana dashboard ID? for API call to export data from the dashboard.
I searched everywhere but I can't find ID for dashboard like in example(The dashboard ID is 942dcef0-b2cd-11e8-ad8e-85441f0c2e5c.).
I'm using ELK stack 7.4.1 OSS(Community version).
You can query your .kibana index from Command Line in your Elasticsearch with something like this;
$ curl -s http://localhost:9200/.kibana/dashboard/_search?pretty
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : ".kibana",
"_type" : "dashboard",
"_id" : "New-Dashboard",
"_score" : 1.0,
"_source" : {
"title" : "New Dashboard",
"hits" : 0,
"description" : "",
"panelsJSON" : "[{\"id\":\"Visualization-VerticalBarChart\",\"type\":\"visualization\",\"panelIndex\":1,\"size_x\":3,\"size_y\":2,\"col\":1,\"row\":1}]",
"optionsJSON" : "{\"darkTheme\":false}",
"uiStateJSON" : "{}",
"version" : 1,
"timeRestore" : false,
"kibanaSavedObjectMeta" : {
"searchSourceJSON" : "{\"filter\":[{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}]}"
}
}
} ]
}
}
Or if you want individual ones you can include the title or the id;
curl -s 'http://localhost:9200/.kibana/dashboard/_search?pretty=1,q=_id=New-Dashboard'
You may refer https://www.elastic.co/guide/en/kibana/current/index.html for more reference
You can find the ID in the URL.
Open the dashboard in Kibana. Extract the part in the URL after <view/> and before <?>.
For http://localhost:5601/app/dashboards#/view/bd1cc200-1169-4ee3-90da-c08d7eaacab5?_g=(filters:!()... the ID is bd1cc200-1169-4ee3-90da-c08d7eaacab5.
API
Alternative you can search and find dashboards using the saved objects API in Kibana:
curl http://localhost:5601/api/saved_objects/_find?type=dashboard
(Using Kibana 7.16)
Trying to load sample data from Kibana using the tutorial : https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html but facing en error of "error" : {
"type" : "illegal_argument_exception",
"reason" : "mapper [geo.coordinates] of different type, current_type [geo_point], merged_type [ObjectMapper]"
curl -H "Content-Type: application/x-ndjson" -XPOST "https://Kibana_username:Kibana_password#cd90859873ee41f2ba44736569855ac6.us-central1.gcp.cloud.es.io:9243/_bulk?pretty" --data-binary #logs.jsonl
{
"index" : {
"_index" : "logstash-2015.05.20",
"_type" : "log",
"_id" : "VLO5SWsB2ropsYqSYd-A",
"status" : 400,
"error" : {
"type" : "illegal_argument_exception",
"reason" : "mapper [geo.coordinates] of different type, current_type [geo_point], merged_type [ObjectMapper]"
}
}
}
]
}
The error that you are getting is because, in your version of logs.json, the content looks like this: {"index":{"_index":"logstash-2015.05.18","_type":"log"}} but if you read the documentation:
Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.
So if you change the file content like this: {"index":{"_index":"logstash-2015.05.18"}}, it would work properly.
But in the latest update of this source file, this error is fixed.
When attempting to delete an item using the following request mapping:
{
"version" : "2017-02-28",
"operation" : "DeleteItem",
"key" : {
"id": { "S" : "$ctx.args.id"},
"sortKey" : { "S" : "$ctx.args.sortKey"}
}
}
If the item exists it will process the result through the response template, however when the item does not exist the response template is never run.
Response template:
#set($ctx.result.status = "SUCCESS")
#set($ctx.result.message = "This was a success!")
$utils.toJson($ctx.result)
I am aware that when an item does not exist in Dynamo it will perform no action but I would expect that it would still process through the template.
Is there anything I am missing or is it impossible for AppSync to processed a DeleteItem request through the response mapping when the document does not exist?
This the expected execution behavior for the version of the template you are using (2017-02-28).
You can switch your request mapping template version to 2018-05-29 and your response mapping template will be executed, with the following characteristics:
If the datasource invocation result is null, the response mapping template is executed.
If the datasource invocation yields an error, it is now up to you to handle the error. The invocation error is accessible using $ctx.error.
The response mapping template evaluated result will always be placed inside the GraphQL response data block. You can also raise or append an error using $util.error() and $util.appendError() respectively.
More info https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-changelog.html#aws-appsync-resolver-mapping-template-version-2018-05-29
So for your example:
{
"version" : "2018-05-29", ## Note the new version
"operation" : "DeleteItem",
"key" : {
"id": { "S" : "$ctx.args.id"},
"sortKey" : { "S" : "$ctx.args.sortKey"}
}
}
and response template
#if ( $ctx.error )
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($ctx.result.status = "SUCCESS")
#set($ctx.result.message = "This was a success!")
$utils.toJson($ctx.result)
Issue
I have probably mucked up the syntax for the JSON query, but cannot for the life of me see where. Trying to create data.frame overviewData grouped on four values with an extra COUNT-feature.
Code
overviewData <- M_CONNECTION$aggregate('[
{
"$group" : {
"_id" : {
"Hotel_Name" : "$Hotel_Name",
"lat" : "$lat",
"lng" : "$lng",
"Average_Score" : "$Average_Score"
},
"COUNT(Hotel_Name)" : {
"$sum" : NumberInt(1)
}
}
},
{
"$project" : {
"Hotel_Name" : "$_id.Hotel_Name",
"lat" : "$_id.lat",
"lng" : "$_id.lng",
"Average_Score" : "$_id.Average_Score",
"COUNT(Hotel_Name)" : "$COUNT(Hotel_Name)",
"_id" : NumberInt(0)
}
}
]',
options = '{"allowDiskUse" : true}'
)
I have quotes around all of my queries, as well as around the options. Still getting an "Invalid JSON object"-error message.
Though I'm not sure, I guess this line is causing you trouble ->
"$sum" : NumberInt(1)
Instead of this, please try this ->
"$sum" : 1
Kindly try this and let me know if this helped.
I have got "Error in Request: No Pax types given" from the response of Bargin Finder Max API and here is my request:
I use json.dumps to turn the dictionary into json.
Can anyone tell me how to solve this?
Have you tried adding the passenger type to the request like the way it's shown in the sample docs?
"AirTravelerAvail" : [ {
"PassengerTypeQuantity" : [ {
"Code" : "ADT",
"Quantity" : 5,
"Changeable" : true
} ]
} ],
I would use just one ADT to test.