Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
We have 2 APIS one to generate SMS other to retrieve and post content of SMS.
http://54.68.219.97:8086//TigoWapPromotion/OmanTelServlet?product=29&service=27465&PID=test
To generate OTP
http://54.68.219.97:8086/IntegrationMServices/Generate_OTP/api/{msisdn}/{PromoID}/{PartnerID}/{TransactionID}
Response:
SUCCESS -
{
"Code": 0,
"Message": "Success",
"TransactionID": "190822141841961ZOTHERZ209Z0Z29224"
}
OR ERROR -
{
"Code": 99,
"Message": "System Error",
"TransactionID": ""
}
To Validate OTP
http://54.68.219.97:8086/IntegrationMServices/OTPValidate/api/{msisdn}/{OTP}/{TransactionID}
Response:
SUCCESS -
{
"Code": 0,
"Message": "Success",
"TransactionID": "190822141841961ZOTHERZ209Z0Z29224"
}
OR ERROR -
{
"Code": 1,
"Message": "PIN Error",
"TransactionID": ""
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have the following environment variable:
$ printenv
...
VCAP_SERVICES={"mariadbent":[{
"label": "mariadbent",
"provider": null,
"plan": "usage",
"name": "stackoverflow-database",
"tags": [
"mariadb",
"mysql"
],
"instance_name": "stackoverflow-database",
"binding_name": null,
"credentials": {
"host": "some-url-to-the-database.service",
"hostname": "some-url-to-the-database.service",
"port": 7689,
"name": "JDFJHDJF_DFJKDHFUD_DFUZDKFJDKJF",
"database": "JDFJHDJF_DFJKDHFUD_DFUZDKFJDKJF",
"username": "hsdfhsjkfhsjkhfjk",
"password": "iuzwerhsdjkfjkasd",
"database_uri": "mysql://dfdfdfdfdf:jrb4j4QxzgbAcfLk#some-url-to-the-database.service:3306/JDFJHDJF_DFJKDHFUD_DFUZDKFJDKJF?reconnect=true",
"uri": "mysql://dfdfdfdfdf:jrb4j4QxzgbAcfLk#some-url-to-the-database.service:3306/JDFJHDJF_DFJKDHFUD_DFUZDKFJDKJF?reconnect=true",
"jdbcUrl": "jdbc:mysql://some-url-to-the-database.service:3306/JDFJHDJF_DFJKDHFUD_DFUZDKFJDKJF?user=dfdfdfdfdf&password=jrb4j4QxzgbAcfLk"
},
"syslog_drain_url": null,
"volume_mounts": [
]
}]}
I can get the whole "pack" of data with System.out.println("VCAP_SERVICES: " + System.getenv("VCAP_SERVICES"));, but I would like to extract some field in the above output, like the username.
How could I do that?
Your VCAP_SERVICE hold an json. You can use an json parser to get a value from it.
Here is an example using Jackson, but there a more libs which can do this.
try{
String json = System.getenv("VCAP_SERVICES"); //NullPointerException, SecurityException
JsonNode jsonNode = (new ObjectMapper()).readTree(json); //IOException
if(jsonNode.has("mariadbent") && jsonNode.get("mariadbent").isArray()){
for(JsonNode elem : jsonNode.get("mariadbent")){
if(elem.has("credentials")){
JsonNode cred = elem.get("credentials");
if(cred.has("host")){
System.out.println(
cred.get("host").asText() //some-url-to-the-database.service
);
}else{ System.out.println("no host"); }
}else{ System.out.println("no credentials"); }
}
}else{ System.out.println("no mariadbent or not array"); }
}catch(Exception e){ e.printStackTrace(); }
For this you need lib Jackson Databind: https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.9.9.3
I need to make some request with the MultiSearch API from Jest.
I tried to build Search request like this :
Search search = new Search.Builder(query).addIndex(index).addType(type).build();
And then, I add all these requests into a collection, to build the MultiSearch and get the result, like this :
List<Search> ms = new ArrayList<Search>();
for (#iterate over#) {
ms.add(search())
//Adding the searches queries to the List
}
MultiSearch multi = new MultiSearch.Builder(ms).build();
MultiSearchResult multir = client.execute(multi);
But this return this error from elasticsearch :
{
"error": {
"caused_by": {
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput#2ccf4bb6; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput#2ccf4bb6; line: 2, column: 3]",
"type": "json_e_o_f_exception"
},
"reason": "Exception when parsing search request",
"root_cause": [
{
"reason": "Exception when parsing search request",
"type": "parse_exception"
}
],
"type": "parse_exception"
},
"status": 400
}
So my question is, how to perform MultiSearch request with jest ?
Well, after tests, I found a solution :
Search search = new Search.Builder(query.toString().replaceAll("\\n|\\r", "")).addIndex(es_index_data)
.addType(es_type_data).build();
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I`m newbie with elasticsearch querybuilder, Could someone give a constructed query for this below one in Java API
curl -XGET "http://localhost:9200/mone/mone/_search?pretty=true" -d'
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "ABC",
"fields": ["Data.Type"]
}
},
"filter": {
"term": { "Data.Date": "01.06.2014" }
}
}
}
}'
Using FilterQueryBuilder I got it to work
FilteredQueryBuilder builder = QueryBuilders.filteredQuery(QueryBuilders.queryString("Spectra"), FilterBuilders.termFilter("Data.Date", "01.06.2014"));
SearchResponse response = elasticClient.prepareSearch("mone")
.setTypes("mone")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(builder)
.execute()
.actionGet();
System.out.println(response);
Hope this answer will be useful to some newbies like me.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to write a program which can create an output in JSON format, how would be best way of doing this? and programming languages?
This is an example output of JSON (expected output) which I need to input in the Name, Gender, Qualification and other attributes in a user friendly way during the execution of script. And in which outputs in following JSON format. Sorry, I am new in programming, but so much interested to learn Perl (or) Python (or) Java. What could be the best here?
Any suggestions?
P.S Sorry I am quite new to JSON as well, please apologize me for this basic one.
[
{
"Name":"Steven Mark",
"gender":"male",
"Qualification": {
"college":"Bachelor in Science",
"tech":"certified pro"
},
"contributions": [
{
"name":"biography",
"type":"book",
},
]
},
{
"Name":"Andrea Mark",
"Gender":"female",
"Qualifications": {
"college":"Bachelor in physics",
},
"contributions": [
{
"name":"my insights",
"type":"movie",
},
]
}
]
Virtually every language has a JSON library, including Perl.
use JSON;
my $data = [
{
"Name" => "Steven Mark",
"gender" => "male",
"Qualification" => {
"college" => "Bachelor in Science",
"tech" => "certified pro"
},
"contributions" => [
{
"name" => "biography",
"type" => "book",
},
]
},
{
"Name" => "Andrea Mark",
"Gender" => "female",
"Qualifications" => {
"college" => "Bachelor in physics",
},
"contributions" => [
{
"name" => "my insights",
"type" => "movie",
},
]
}
];
print(encode_json($data));
If you agree to use ANY programming language, i can suggest python. With its json lib you can do following (lines with # is comments):
# import lib
import json
# fill data into variable (this is list with dict objects inside):
data = [{"name":"john"},{"name": "bill"}]
# dump json
json.dumps(data)
Which will output your data as json.
You can start writing python using something from https://wiki.python.org/moin/BeginnersGuide
If you are going to use Python, you can try to use simplejson or json module to create a json object.
For example,
try:
import simplejson
except:
import json
data = dict(a=1,b=2)
with open("results.json", "w") as fp:
json.dump(data, fp, indent=3, encoding="utf-8")
For dumping, json is faster than simplejson (but not by an order of magnitude). For loading, simplejson is faster (but not by an order of magnitude).
You can check here for more detailed comparison between simplejson and json.
This question already has answers here:
Get latitude and longitude based on location name with Google Autocomplete API
(7 answers)
Closed 10 years ago.
Is there a way by which I can find latitude and longitude of a known place e.g. known city like Singapore, Kuala Lumpur / New York.
Geocoding
Check out: Google Geocoding API
Ask google.
e.g.
This http request:
http://maps.google.com/maps/geo?q=Singapore
returns:
{
"name": "Singapore",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [ {
"id": "p1",
"address": "Singapur",
"AddressDetails": {
"Accuracy" : 1,
"Country" : {
"CountryName" : "Singapur",
"CountryNameCode" : "SG"
}
},
"ExtendedData": {
"LatLonBox": {
"north": 1.4708809,
"south": 1.1663980,
"east": 104.0856805,
"west": 103.6056246
}
},
"Point": {
"coordinates": [ 103.8198360, 1.3520830, 0 ]
}
} ]
}