restful api get not work,but scan can work - ignite

anybody know why restful api scan has data
http://127.0.0.1:8080/ignite?cmd=qryscanexe&pageSize=5&cacheName=contact
result
{
"successStatus": 0,
"error": null,
"sessionToken": null,
"response": {
"items": [
{
"key": {
"id": 703896957108224
},
"value": {
"mergedId": null,
"priority": 0,
"identities": [
{
"id": "7",
"type": "idCard",
"dateCreated": 1652932875433,
"lastUpdated": 1652932875433
}
],
"followerIds": [],
"contactType": "LEADER",
"dateCreated": 1652932875433,
"lastUpdated": 1652932875433
}
}
],
"last": true,
"queryId": 2,
"fieldsMetadata": [
{
"schemaName": null,
"typeName": null,
"fieldName": "key",
"fieldTypeName": null
},
{
"schemaName": null,
"typeName": null,
"fieldName": "value",
"fieldTypeName": null
}
]
}
}.
but get command no result.
http://127.0.0.1:8080/ignite?cacheName=contact&cmd=get&keyType=ContactKey&key={"id":703896957108224}
result
{
"successStatus": 0,
"affinityNodeId": "ee5e4d0d-5c91-4b9d-b68f-5dfac2f45908",
"error": null,
"sessionToken": null,
"response": null
}

By default Ignite REST supports Java built-in types for get/put operations. But it should be possible to implement a custom serialization if needed. In general it's much better to use Ignite thin clients, it's more functional than REST.

Related

POST request failed from Postman to Jdoodle API

I have created an account on jdoodle and buy a free plan in which we can make 200 requests per days and from there I got credentials (clientId and clientSecret) for making request to their api .
I am making post request from postman to Jdoodle api. It is giving me response as unauthorized request with status code 401 in spite of valid credentials.
Giving me unauthorised request error also when i make request for checking credits used or (how many calls I have made to their api).
POST- https://api.jdoodle.com/v1/execute/
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"script" : "console.log('hello')",
"language" : "nodejs",
"versionIndex" : "0"
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
POST- https://api.jdoodle.com/v1/credit-spent
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
I don't know why I am getting such response inspite of all valid credentials and parameters.
Use this postman collection. Mostly it looks like your issue is with auth. make sure if client_id and secret are safely substituted.
{
"auth": null,
"event": null,
"info": {
"_postman_id": null,
"description": null,
"name": "JDoodle Compiler API.http",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"version": null
},
"item": [
{
"description": null,
"event": null,
"id": null,
"name": "Execute Program",
"protocolProfileBehavior": null,
"request": {
"auth": null,
"body": {
"disabled": null,
"file": null,
"formdata": null,
"graphql": null,
"mode": "raw",
"options": {
"language": "json"
},
"raw": "{\"clientId\": \"{{clientId}}\", \"clientSecret\": \"{{clientSecret}}\", \"script\": \"print 'hello'\", \"language\": \"python2\", \"versionIndex\": \"0\"}",
"urlencoded": null
},
"certificate": null,
"description": "Execute Program",
"header": [
{
"description": null,
"disabled": false,
"key": "content-type",
"value": "application/json"
}
],
"method": "POST",
"proxy": null,
"url": "https://api.jdoodle.com/v1/execute/"
},
"response": null,
"variable": null,
"auth": null,
"item": null
}
],
"protocolProfileBehavior": null,
"variable": [
{
"description": null,
"disabled": false,
"id": null,
"key": "baseUrl",
"name": null,
"system": null,
"type": null,
"value": "httpsDefaultParameterValue:DefaultParameterValue#DefaultParameterValue.myshopify.com/"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "id",
"name": null,
"system": null,
"type": null,
"value": "<post>"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "event_id",
"name": null,
"system": null,
"type": null,
"value": "<>"
}
]
}
With dothttp request is far simple and easily sharable
#name("Execute Program")
POST "https://api.jdoodle.com/v1/execute/"
json({
"clientId": "{{clientId}}",
"clientSecret": "{{clientSecret}}",
// "script": '<?php echo "hello"; ?>',
// "language": "php",
"script" :"print 'hello'",
"language": "python2",
// "stdin": "",
"versionIndex": "0"
})

how to convert json response to List in c# RestSharp

Currently I am working on asp .NET 5 console application with Restsharp, My Api Get request is working on postman, but I am struggling to convert this json object to a list .
This is my json object:
"data": {
"domain": "intel.com",
"disposable": false,
"webmail": false,
"accept_all": false,
"pattern": "{first}.{last}",
"organization": "Intel",
"country": "US",
"state": null,
"emails": [
{
"value": "danielle.sikich#intel.com",
"type": "personal",
"confidence": 99,
"sources": [
{
"domain": "github.com",
"uri": "http://github.com/hpc/mpifileutils",
"extracted_on": "2021-10-28",
"last_seen_on": "2021-10-28",
"still_on_page": true
}
],
"first_name": "Danielle",
"last_name": "Sikich",
"position": null,
"seniority": null,
"department": null,
"linkedin": null,
"twitter": null,
"phone_number": null,
"verification": {
"date": "2021-11-05",
"status": "valid"
}
},
I tried this but its not working:
List<Job> JobList = JsonConvert.DeserializeObject<List<Job>>(jsonResponse["data"]["emails"]["value"].ToString());

azure search exact match of file name not returning exact results

I am indexing all the file names into the index. But when I search with exact file name in the search query it is returning all other file names also. below is my index definition.
{
"fields": [
{
"name": "id",
"type": "Edm.String",
"facetable": true,
"filterable": true,
"key": true,
"retrievable": true,
"searchable": false,
"sortable": false,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "FileName",
"type": "Edm.String",
"facetable": false,
"filterable": false,
"key": false,
"retrievable": true,
"searchable": true,
"sortable": false,
"analyzer": "keyword-analyzer",
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
}
],
"scoringProfiles": [],
"defaultScoringProfile": null,
"corsOptions": null,
"analyzers": [
{
"name": "keyword-analyzer",
"#odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"charFilters": [],
"tokenizer": "keyword_v2",
"tokenFilters": ["lowercase", "my_asciifolding", "my_word_delimiter"]
}
],
"tokenFilters": [
{
"#odata.type": "#Microsoft.Azure.Search.AsciiFoldingTokenFilter",
"name": "my_asciifolding",
"preserveOriginal": true
},
{
"#odata.type": "#Microsoft.Azure.Search.WordDelimiterTokenFilter",
"name": "my_word_delimiter",
"generateWordParts": true,
"generateNumberParts": false,
"catenateWords": false,
"catenateNumbers": false,
"catenateAll": false,
"splitOnCaseChange": true,
"preserveOriginal": true,
"splitOnNumerics": true,
"stemEnglishPossessive": false,
"protectedWords": []
}
],
"#odata.etag": "\"0x8D6FB2F498F9AD2\""
}
Below is my sample data
{
"value": [
{
"id": "1",
"FileName": "SamplePSDFile_1psd2680.psd"
},
{
"id": "2",
"FileName": "SamplePSDFile-1psd260.psd"
},
{
"id": "3",
"FileName": "SamplePSDFile_1psd2689.psd"
},
{
"id": "4",
"FileName": "SamplePSDFile-1psdxx2680.psd"
}
]
}
Below is the Analyze API results
{
"tokens": [
{
"token": "samplepsdfile_1psd2689.psd",
"startOffset": 0,
"endOffset": 26,
"position": 0
},
{
"token": "samplepsdfile",
"startOffset": 0,
"endOffset": 13,
"position": 0
},
{
"token": "psd",
"startOffset": 15,
"endOffset": 18,
"position": 1
},
{
"token": "psd",
"startOffset": 23,
"endOffset": 26,
"position": 2
}
]
}
When I search with the keyword "SamplePSDFile_1psd2689.psd", Azure search returning three records in the results instead of only document 3. Below is my search query and the results.
?search="SamplePSDFile_1psd2689.psd"&api-version=2019-05-06&$count=true&queryType=full&searchMode=All
{
"#odata.count": 3,
"value": [
{
"#search.score": 2.3387241,
"id": "2",
"FileName": "SamplePSDFile-1psd260.psd"
},
{
"#search.score": 2.2493405,
"id": "3",
"FileName": "SamplePSDFile_1psd2689.psd"
},
{
"#search.score": 2.2493405,
"id": "1",
"FileName": "SamplePSDFile_1psd2680.psd"
}
]
}
How I can achieve my expected results. I tried with and without double quotes around the keyword all other options, but no luck. What I am doing wrong here in this case?
Some body suggested to use $filter, but that field wasn't filterable in our case.
Please help me on this.
If you are looking for exact match then you probably don't want any analyzer involved. Give it a try with this line
"analyzer": "keyword-analyzer"
changed to
"analyzer": null
If you need to be able to do exact match on the field and also support partial keyword searches then you need to index the field twice with different names. Maybe append “Exact” to the exact match field name and don’t use an analyzer for that one. The name without exact can have an analyzer. Then search on the field using the right field name index depending on the type of search.

ASPNET Core 3.x - Appending data to all API responses

I've been googling for past 3 hours and I couldn't find anything helpful.
I'm trying to transform all my requests to a specific RESTful standard.
Right now, each and every controller returns data in this format:
[
{
"id": 3,
"title": "Test",
"content": "Content Test",
"userId": 1,
"user": null,
"categoryId": null,
"category": null,
"comments": null,
"tags": null,
"createdOn": null,
"updatedOn": null
}
]
What I want is to wrap all of these responses in a container, that also consists of metadata - as seen below:
{
"statusCode": 200,
"statusMessage": "success",
"meta":
{
"count": 1,
"total": 1,
"pagination":
{
"page": 1,
"pages": 1,
"limit": 20
},
"filters": [],
"sorters": []
},
"data":
{
[
{
"id": 3,
"title": "Test",
"content": "Content Test",
"userId": 1,
"user": null,
"categoryId": null,
"category": null,
"comments": null,
"tags": null,
"createdOn": null,
"updatedOn": null
}
]
}
}
Is the proper approach to just make a class called ResponseContainer and make all controllers return it? Because I feel like that's a viable solution.
In one of my projects, I used a generic class as response, such as MyApiResponse<T>. This class contains properties for meta data like the HttpStatusCode of the response, error messages, etc. They are set upon each response.
Within this class, I have a List<T> called Data.
Each API method returns MyApiResponse<T> where T is being the concrete data class. For instance, it could be MyApiResponse<Weather> where Data would store a List<Weather.
I'll definetly use this approach for my next API project as well.

Access subscription details with Stripes Webhooks PHP

I haven't been able to find any details for this with PHP, so I am hoping somebody can help me complete this script?
I am searching for the Subscription details from the Stripe API Webhook event. The event I am working on is invoice.payment_succeeded although I am struggling to access the subscription information from this. Here is the test event in full:
{
"id": "evt_19HdmRL346436RYAmvgxkr",
"object": "event",
"api_version": "2016-07-06",
"created": 1479580899,
"data": {
"object": {
"id": "in_19HdmRLniq434634643dO2gU",
"object": "invoice",
"amount_due": 700,
"application_fee": null,
"attempt_count": 1,
"attempted": true,
"charge": "ch_19Hdm3463464365IDDXX",
"closed": true,
"currency": "gbp",
"customer": "315464619",
"date": 1479580899,
"description": null,
"discount": null,
"ending_balance": 0,
"forgiven": false,
"lines": {
"object": "list",
"data": [
{
"id": "sub_9apRC346346CMNg",
"object": "line_item",
"amount": 700,
"currency": "gbp",
"description": null,
"discountable": true,
"livemode": false,
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
},
"period": {
"start": 1479580899,
"end": 1482172899
},
"plan": {
"id": "AdFree",
"object": "plan",
"amount": 700,
"created": 1479261871,
"currency": "gbp",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "AdFree",
"statement_descriptor": "SNAPPYSITES ADFREE",
"trial_period_days": null
},
"proration": false,
"quantity": 1,
"subscription": null,
"type": "subscription"
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/invoices/in_19HdmRLn34353465dO2gU/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"paid": true,
"period_end": 1479580899,
"period_start": 1479580899,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"subscription": "sub_9a2552OA5553MNg",
"subtotal": 700,
"tax": null,
"tax_percent": null,
"total": 700,
"webhooks_delivered_at": null
}
},
"livemode": false,
"pending_webhooks": 1,
"request": "req_9apRx9555ZVm55",
"type": "invoice.payment_succeeded"
}
I am currently listening with this unfinished script:
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
$event_id = $event_json->id;
$event = \Stripe\Event::retrieve($event_id);
if($event->type == 'invoice.payment_succeeded'){
$invoice = $event->data->object;
$subscription = $invoice->lines->data->plan;
$customer = \Stripe\Customer::retrieve($invoice->customer);
print_r($subscription);
}
Unfortunately I'm not getting any response from the $subscription array. And I have attempted various methods, such as; $subscription = $invoice->plan; or $subscription = $invoice->data->plan; etc...
I do receive data for $invoice & $customer so I know they both function correctly. My main focus is to retrieve the Metadata information:
"metadata": {
"website_ref": "Z8ckRo2x",
"user_id": "1"
}
So I know which account this payment relates to. Hoping somebody might know what I'm doing wrong.
Have you tried $invoice->lines->data->Metadata->website_ref to get the metadata you are after?
Your Invoice consists of a list of subscriptions, in this case just 1. Each subscription is a result of the user selecting a plan. The metadata is stored at the subscription level as it's specific for the customer, not on the plan.