How to add JSON array to elasticsearch using Postman - elasticsearch

I have tried to add sample data set using postman as following way,
POST URL: http://localhost:9200/allData
Add to postman body as json
{
"index": "allData",
"type": "all",
"id": 1006,
"body": {
"id": 1006,
"url": "https://en.wikiversity.org/wiki/Principles_of_Management",
"title": "Principles of Management",
"author": "",
"rate": 0,
"ratedBy": 0,
"datePublished": "2018-01-01T00:00:00",
"publishedDate": "2018-01-01"
}
}
But it is given following error.
No handler found for uri [/] and method [POST]
Someone please help me to solve this issue. Thanks

There are certain issues with your request:
Elasticsearch index names cannot have uppercase so in your case it should be alldata not allData.
The format of the URL is wrong.
Your URL should be in the below format:
http://localhost:9200/{indexname}/{type}/{id}
which in your case must be:
http://localhost:9200/alldata/all/1006
So you should perform a POST request to the above url with the body as:
{
"id": 1006,
"url": "https://en.wikiversity.org/wiki/Principles_of_Management",
"title": "Principles of Management",
"author": "",
"rate": 0,
"ratedBy": 0,
"datePublished": "2018-01-01T00:00:00",
"publishedDate": "2018-01-01"
}
Have a look at the Elasticsearch Reference Guide.
Hope it helps !

Related

Cannot retreive virtual card number in test mode via stripe API using Go examples

Trying to follow the example here: https://stripe.com/docs/issuing/cards/virtual
When I add params.AddExpand("number"), no number is returned, yet via the dashboard I was able to see the card numbers. Here's sample code and redacted info for the Req and Resp.
func (ac *appContext) CardRetrieve(id string) *stripe.IssuingCard {
stripe.Key = ac.Config.Stripe.SecretKey
params := stripe.IssuingCardParams{}
params.AddExpand("number")
params.AddExpand("cvc")
ic_num, _ := card.Get(id, &params)
return ic_num
}
Returns:
{
"id": "ic_redacted",
"object": "issuing.card",
"brand": "Visa",
"cancellation_reason": null,
"cardholder": {
"id": "ich_redacted",
"object": "issuing.cardholder",
"billing": {
"address": {
"city": "A Beach",
"country": "US",
"line1": "404 Main St.",
"line2": "Suite #302",
"postal_code": "19001",
"state": "DE"
}
},
"company": null,
"created": 1613338532,
"email": "redacted#notreal.com",
"individual": {
"dob": {
"day": 20,
"month": 10,
"year": 1990
},
"first_name": "User",
"last_name": "Testing",
"verification": {
"document": {
"back": null,
"front": null
}
}
},
"livemode": false,
"metadata": {
},
"name": "User Testing",
"phone_number": "+15165551212",
"requirements": {
"disabled_reason": "under_review",
"past_due": [
]
},
"spending_controls": {
"allowed_categories": [
],
"blocked_categories": [
],
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "active",
"type": "individual"
},
"created": 1613338532,
"currency": "usd",
"exp_month": 1,
"exp_year": 2024,
"last4": "0088",
"livemode": false,
"metadata": {
},
"replaced_by": null,
"replacement_for": null,
"replacement_reason": null,
"shipping": null,
"spending_controls": {
"allowed_categories": null,
"blocked_categories": null,
"spending_limits": [
{
"amount": 1,
"categories": [
],
"interval": "daily"
}
],
"spending_limits_currency": "usd"
},
"status": "inactive",
"type": "virtual"
}
What confuses me is the documentation found here:
https://stripe.com/docs/issuing/cards/virtual
It says: You can retrieve both the full unredacted card number and CVC from the API. For security reasons, these fields are only available for virtual cards and will be omitted unless you explicitly request them with the expand property. Additionally, they are only available through the Retrieve a card endpoint. That links to the issue card retrieval end point, but the params defined in the virtual cards example references the CardParams{} struct.
No of the examples show what imported module their aliasing for card to exec card.Get, but it stands to reason given the flow of the documentation that this should be IssuingCardParams{} and that the card alias is referencing: "github.com/stripe/stripe-go/issuing/card"
I also find it strange that we're defining params in the example but not passing it into the card.Get()
Edit:
I went digging through the module and it seems like to get the card details you have to call: details, _ := card.Details(id, params) but I get a 404 when trying to call that. The object returned is actually the right object and I see number and cvc, albeit nil.
I get the following error:
2021/02/15 00:33:06 Request error from Stripe (status 404): {"status":404,"message":"Unrecognized request URL (GET: /v1/issuing/cards/ic_redacted/details). Please see https://stripe.com/docs
So it seems you need to include a /v72 in the import:
"github.com/stripe/stripe-go/v72"
The documentation should be updated to show this and the virtual card example for go should also be updated.

How to extract multiple json values from a Json response

I am trying to extract multiple values from a JSON response on my jmeter script. Below is sample of my response:
{
"startDate": "2018-12-10T15:36:34.400+0000",
"userId": "7211111-2fa90",
"createdBy": "TEST",
"note": {
"content": "Application Submitted "
},
"Type": "SUBMITTED"
},
"currentEventState": "CLOSED",
{
"Xxxx": "test",
"Loc": null,
"Zipcode": [],
"Locality": 82,
"Address": {
"Add": 12302,
"Add2": "place",
"Zip": {
"Phone": "home",
"Email": "test#test.com"
}
},
"state": "MD",
"Cost": "E "
},
"AppID": "cd8d98e6-c2a79",
"Status": "CLOSED",
}
I am trying to extract userid and AppID for the case if the TYPE is Submitted and Status is Closed.I tried using the Json extractor with $.[?(#.Type=="SUBMITTED")].[*].?(#.Status=="CLOSED").userid,APPID, but couldn't get the expected result. Could anyone guide me on this.
You need to use an inline predicate to combine 2 clausees and a semicolon in order to store results into 2 separate JMeter Variables.
Add JSON Extractor as a child of the request which returns above JSON
Configure it as follows:
Names of created variables: userid;appid
JSON Path Expressions: $..[?(#.Type=='SUBMITTED' && #.Status == 'CLOSED')].userId; $..[?(#.Type=='SUBMITTED' && #.Status == 'CLOSED')].AppID
Default values: NA;NA
Here is the demo of single expression working fine:
And here are extracted values reported by the Debug Sampler:

Jmeter : How to extract first element from json array

I am trying to extract first element from a json array. Below mentioned is json array
[
{
"cohortDefinition": {
"Key": 1151,
"id": 1798,
"srcId": "3526",
"pcKey": -1,
"userName": "CHROME_USER",
"name": "JMeter2017-01-06-1483749546167",
"Type": "SUBJECT",
"tool": "CB",
"count": 32757,
"extractionStatus": "",
"dateCreated": "2017-05-10T17:48:45Z"
},
"datasource": {
"id": 2,
"name": "health",
"subjectCount": 116352
},
"project": {
"id": 747,
"name": "Jmeter Project"
}
},
{
"cohortDefinition": {
"Key": 1150,
"id": 1796,
"srcId": "3525",
"pcKey": -1,
"userName": "CHROME_USER",
"name": "JMeter2016-10-27-1477620919644",
"Type": "SUBJECT",
"tool": "CB",
"count": 32757,
"extractionStatus": "",
"dateCreated": "2017-05-10T16:57:11Z"
},
"datasource": {
"id": 2,
"name": "health",
"subjectCount": 116352
},
"project": {
"id": 747,
"name": "Jmeter Project"
}
}
]
From above json i would like to extract first value ie. srcId": "3526".
I tried doing following expression in Jmeter extractor
$..cohortDefinition.srcId[1]
However it is not working. If anyone know how to do this please do let me know.
After JMeter 3.0, you can use JSON Extractor, see:
https://stackoverflow.com/a/47043204/460802
Before JMeter 3.0:
Please follow the below steps to retrieve srcId.
Add a JSON Path Extractor to your request and configure below values.
Destination Variable Name - myVar
JSON Path Expression - $..cohortDefinition.srcId - this will extract all the srcIDs from the JSON.
Default Value - Not Found or Err
Add a Debug Sampler and View Results Tree to your test plan.
Save it and execute.
In Debug Sampler, you can view all the srcId as shown below.
You can now use myVar_1 and myVar_2 in your test plan
using ${myVar_1} ${myVar_2}
No need for Plugin, JMeter has a JSON Extractor that will provide this feature:
Notice:
JSON Path Expression is: $..cohortDefinition.srcId
Match No : 1

Search query on Okta Users API

I am trying to run a query in our instance of okta using postman. The problem I am running into is that Postman says it has syntax errors. Exact wording "Invalid search criteria.". Here is a partial copy copy of my structure:
{
"id": "00u1c9lvdpsArq00J0h8",
"status": "ACTIVE",
"created": "2017-02-28T18:55:23.000Z",
"activated": "2017-02-28T18:55:24.000Z",
"statusChanged": "2017-02-28T18:55:24.000Z",
"lastLogin": null,
"lastUpdated": "2017-05-01T10:30:59.000Z",
"passwordChanged": null,
"profile": {
"login": "lynn#enterthepicture.com",
"firstName": "Lynn",
"lastName": "Harvey",
"mobilePhone": null,
"email": "lynn#enterthepicture.com",
"secondEmail": null,
"primaryPhone": "4169329890"
},
"credentials": {
"provider": {
"type": "ACTIVE_DIRECTORY",
"name": "idm.sni"
}
},
The query I am trying to run is {{url}}/api/v1/users?search=credentials.provider.name eq "idm.sni"
If anyone has any suggestion I would greatly appreciate the help.
The search expression needs to be URL encoded, an example can be found here: http://developer.okta.com/docs/api/resources/users.html#list-users-with-search
So in your example, the request URL would need to look like {{url}}/api/v1/users?search=credentials.provider.name%20eq%20%22idm.sni%22.
I hope this helps!

Find all users within a thread of gmail API

I am using the gmail API to get recent hangouts messages/threads. But I can't find a way to view the recipient address. The only field in payload.headers is 'From'
code:
curl -H 'Authorization: Bearer **accessToken**' 'https://www.googleapis.com/gmail/v1/users/me/threads/**threadId**?q=is%3Achat'
response:
{
"id": "xxx",
"historyId": "1008967",
"messages": [{
"id": "xxx",
"threadId": "xxx",
"labelIds": [
"CHAT"
],
"snippet": "+Harry Howard",
"historyId": "1008953",
"internalDate": "1481641738948",
"payload": {
"partId": "",
"mimeType": "text/html",
"filename": "",
"headers": [{
"name": "From",
"value": "xxx"
}],
"body": {
"size": 13,
"data": "K0hhcnJ5IEhvd2FyZA=="
}
},
"sizeEstimate": 100
}]
}
In the case of emails, there is a 'To' field ( and sometimes cc etc).
FYI: I am using node-gmail-api npm module but just testing this with curl
Use Users.threads:list to find all users within a thread. See an example here.
HTTP request
GET https://www.googleapis.com/gmail/v1/users/userId/threads
This request requires authorization with at least one of the following scopes
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.metadata
Response
If successful, this method returns a response body with the following structure:
{
"threads": [
users.threads Resource
],
"nextPageToken": string,
"resultSizeEstimate": unsigned integer
}

Resources