JSON webhook through WP Automator - Custom Syntax - arrays

I have this JSON code:
{
"Subscribers": [
{
"EmailAddress":"yikes#to.com",
"CustomFields": [
],
"Lists": [
200575230
]
}
]
}
I tested it on Postaman, it works - it should push email address of every new registered user to the Campaigner.
But, for automation I use WP automator webhooks in Wordpress. For creation of this automation I can't use this above code, but code formatted per Automator "syntax".
In Automator, for example - this code below:
data": {
"customer": 123,
"first_name": "AutomatorWP",
}
Is mapped like this:
data/customer
data/first_name
And for the brackets - "The brackets ([]) place the information inside an array, so you need to place the array index like “data/0/first_name” to use this “first_name” parameter on tags." - Documentation
Does anyone knows or can figure out how to above first code "translate" to this Automator layout?
I tried with:
Subscriber/EmailAddress and Subscriber/0/EmailAddress - but I can't figure out how to send email to the right list, as simple as it is in clean JSON code
Any help appreciated
I tried any possible variation, always same error: Invalid Payload
I don't have any idea anymore, so maybe somebody worked earlier with this Automator "syntax"

Related

Gatling - Extract Json value from previews request

I'm new in Gatling, and trying to get value from json key.
This check give me labels:
.check(jsonPath("$[1].ppp[1].label").saveAs("label"))
In this request i got all json data like this
[
{
"id":258,
"code":"D00CC3056",
"label":"Test-0"
},
{
"id":260,
"code":"D00RR148",
"label":"Test-1"
}
]
From this Json, i need to get code value from a specific label, to use it in request after.
Something like : get code where label is "Test-1".
I've trying this but doesn't works:
.exec(
http("request_3:GET_/api/code")
.get("/api/code")
.check(status.is(200))
.check(jsonPath("$..[*].code").find("{$label}").saveAs("code"))
)
I don't know how to do this.
Any help ?
With JMESPath that you should really learn and that Gatling supports:
.check(jmesPath("[?label == 'Test-1'].code").saveAs("code"))

Elasticsearch watcher email array value

I am working on ELK watcher to create an alert that sends an array of value transformed using 'transform' mapping.
"transform": {
"script": "return [ err_yest : ctx.payload.aggregations.errorcount.buckets.collect { [err_count:it.doc_count, list_errors: it.errs.buckets.collect{[emsg:it.key,emsc:it.doc_count]}] } ]"
},
Is there a way to print the array values in the body of email alert using any looping method? I tried groovy scripting, but got an error saying it's unsupported. All I could do is manually printing the values in array like below.
"body" : {
"html": "<table width='400px' border='1'><thead><tr><th colspan='4'>Error Messages</th></tr><tr><th colspan='2'>Yesterday</th><th colspan='2'>Today</th></tr></thead><tbody><tr><td>{{ctx.payload.err_yest.0.list_errors.0.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.0.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.0.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.0.emsg}}</td></tr><tr><td>{{ctx.payload.err_yest.0.list_errors.1.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.1.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.1.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.1.emsg}}</td></tr><tr><td>{{ctx.payload.err_yest.0.list_errors.2.emsc}}</td><td align='center'>{{ctx.payload.err_yest.0.list_errors.2.emsg}}</td><td>{{ctx.payload.err_yest.1.list_errors.2.emsc}}</td><td align='center'>{{ctx.payload.err_yest.1.list_errors.2.emsg}}</td></tr></tbody></table>"
},
You need to use Mustache templating
The syntax is something like this :
{{#ctx.payload.err_yest}} {{#list_errors}} {{emsc}} {{/list_errors}}{{/ctx.payload.err_yest}}
This will loop over all the objects in err_yest then loop over all the list_errors for a err_yest object and display esmc

Referencing arrays that are nested within multiple objects within MongoDB with Express js

So in my MongoDB Collection I have this structure:
"_id" : "Object("-----------")
"name" : "John Doe"
"tool" : {
"hammer" : {
"name" : "hammer 1",
"characteristics" : [
{
"length" : "9 inches"
},
{
"weight" : "4 pounds"
}
]
I know the data may seem a little strange but I can't put the actual data online so I had to input some dummy data. So essentially what I would like to do is be able to update the array that is nested within those objects. So I would like to be able to update the weight or add a new characteristic that I haven't previously entered into it. So for example, add in "metal" : "steel" as a new entry into the array. Currently I'm using a Rest API built in Node.js and Express.js to edit the db. When I was trying to figure out how to dig down this deep I was able to do it with an array at the highest level, however I haven't been able to figure out how to access an array when its embedded like this. So what I was wondering if anybody knew if it was even possible to edit an array this far down? I can post code from controller.js and server.js file if needed but I figured I'd see if it's even possible to do before I start posting it. Any help would be greatly appreciated!
You can use findAndModify to $push it into the array. You have to specify the path precisely though:
db.tools.findAndModify( {
query: { name: "John Doe"},
update: { $push: { tool.hammer.characteristics: {metal: "steel"} }
} );

Selenium IDE cannot find ID

I recorded a test with Selenium IDE but when I try to run the test I get an error [error] Element id=jsonform-0-elt-businessActor not found
I also noticed this particular field's id is slightly different.. The rest of the fields have this format id=jsonform-0-elt-0.nameOfJsonAttribute
Could there be any reason why the bussinessActor ID is not working and captured differently?
JsonSchema used to render the form:
{
"type":"object",
"id": "001",
"title": "testSchema",
"properties":{
"businessActor": {
"type":"string",
"title": "Name",
"description": "example of a description."
}
}
}
Note: Am using jsonForm to render the form based on json shema. Form id's are generated dynamically by jsonFom. And am also using Angular.js (angular is not playing a role in this aprticular issue, I think)
As #MarkRowlands suggested, it sounds like your page is dynamic.
Try this out as your target...
css=[id^='jsonform'][id$='businessActor']
^= means 'starts with' in css. $= means 'ends with' in css.
Change that selector to match whatever you would like to select.

Use of "creator" property in timetime insert doesn't seem to work

The playground has an example card that includes a "creator" field with the name and an image representing "Google Glass". The JSON used to create this card is
{
"text": "Hello Explorers,\n\nWelcome to Glass!\n\n+Project Glass\n",
"creator": {
"displayName": "Project Glass",
"imageUrls": [
"https://lh3.googleusercontent.com/-quy9Ox8dQJI/T3xUHhub6PI/AAAAAAAAHAQ/YvjqA3Pw1sM/glass_photos.jpg?sz=360"
]
},
"notification": {
"level": "DEFAULT"
}
}
When this is sent to Glass, however, the imageUrl isn't displayed. The documentation at https://developers.google.com/glass/v1/reference/timeline/insert simply says that "creator" is a "nested object", but with no clear indication what this nested object should be. The example seems to indicate that this should be a Contact (see https://developers.google.com/glass/v1/reference/contacts), and the object returned by the insert seems to be of type "mirror#contact", confirming this.
Does the contact used in a creator need to be pre-created via the contacts API call first? Is there something else necessary to get the creator to display or work correctly?
The creator is currently displayed only if the REPLY menu item is provided along with the timeline item.
This seems like a bug, please file it on our issue tracker

Resources