MS Flow (Azure) and Double quote - azure-logic-apps

I hope you can help me as I'm a little stuck on this problem and cannot find a nice solution.
I would like to create an HTTP POST and the body of my request need to be something like this
.... (code)
{
"table":"DimDate"
}
.... (code)
The "table" : "Dimdate" is built , part by a string variable ( myVar='{"table":"' ) and a dynamic field (all stored on another string variable called myString).
Meaning I've got on my MS Flow a variable myString = "table": "DimDate"
Till there no issue. My problem appear when I want to embed my variable in the body of the HTTP Post.
It seems all is converted as
.... (code)
{
\"table\":\"DimDate\"
}
.... (code)
Question is why do I have those "\" ? and how to remove them ?
I've check and it seems they appear by default from the start , in my different variables. How to remove them when I use the variable myString in the HTTP POST body ?
I've already try to convert to plain-text, look for use char (no idea how), etc...
Any idea ?
Thanks
Addendum
a) Idea is to be able to add in the body of my HTTP POST the following body
{
"CommitMode": "transactional",
"MaxParallelism": 2,
"Objects": [
{ "Table": "table1" },
{ "Table": "table2"},
{ "Table": "table3"}
],
"RetryCount": 2,
"Type": "Full"
}
b) For that I set an initial variable _mystring as '{"table":"'
c) with a loop I put in a variable _myVar a concatenation of _mystring with a array of table ( table1,2 and 3) . the variable _myVar at the end is ok. No issue there
d) the HTTP POST body appear on the screen "as this" :
{
"CommitMode": "transactional",
"MaxParallelism": 4,
"Objects": [
{
"Table": "#{variables('_Table')}"
}
],
"RetryCount": 2,
"Type": "Full"
}
e) Like that all appear perfect. The problem is that when I run the flow, the body of the HTTP is not OK as even the variable _mystring which is used. It seems the " is replaced by \" and this generate a wrong output of the HTTP POST.
Is there a way to avoid Microsoft Flow replace the " by \" ?
Miguel

Finally an easy solution was found.
Microsoft fix that during their next Logic App release.
Topic close

Related

JSON webhook through WP Automator - Custom Syntax

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"

How to use Dialog.ElicitSlot for Python as Runtime environment

I want to fill a slot not at the beginning of the invocation of the intent, but at a later part in the intent request. I want to provide user some options, and I want them to select one out of those. For that I'm trying to use Dialog.ElicitSlot, but somehow I'm getting an error :
"Request to skill endpoint resulted in an error."
I'm returning this when I need the user to select an option from my list.
return {
"version": "1.0",
"sessionAttributes": {},
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "These are the multiplex" + ("es" if len(multi_list) > 1 else "") + " " + outputSpeech + ". Please select one out of these."
# outputSpeech contains the list of options I want the user to select from
},
"shouldEndSession": False,
"directives": [
{
"type": "Dialog.ElicitSlot",
"slotToElicit": "MULTIPLEX",
"updatedIntent": {
"name": "GetMovieDetails",
"confirmationStatus": "NONE",
"slots": {
"CITY" : {
"name" : "CITY",
"confirmationStatus" : "NONE",
"value" : city # this is already filled, it is just anti-capitalised
},
"NAME" : {
"name" : "NAME",
"confirmationStatus" : "NONE",
"value" : movie_name # this is already filled, it is just anti-capitalised
},
"MULTIPLEX" : {
"name" : "MULTIPLEX",
"confirmationStatus" : "NONE",
}
}
}
}
]
}
I'm testing my skill using python-lambda-local, it is working fine on my local machine (I just had to change the dialogState to "COMPLETED" manually, like the one here). It returns everything written above. But It gives an error while testing it on Skill Tester. Here is the output which is returned in the Skill Tester.
PS : I did not check the Slot Filling check box in the Build Section. (As I need the slot to be filled later), and here is the complete code just in case.
Try with omitting the entire "updatedIntent" part, as this information is not required for ElicitSlot.
But more important: You have to make sure that your script returns actual text in JSON-format!
Have a look at http://flask.pocoo.org/docs/1.0/api/#flask.json.jsonify
or https://docs.python.org/2/library/json.html
God, I hate to admit this.
The Dialog.ElicitSlot works fine, and the way I expect it to do so.
The error with my code is, there is no error. I figured my skill was taking some time to fetch data from remote site and doing some calculations on it. So I increased the time out and bam, it worked.
It is always a better to test your skill locally, but it is great to test it once on the aws lambda console. I don't know why I didn't do that earlier.
So to conclude, I just had to increase the timeout in my skill.

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

SoapUI: Count Nodes Returned in JSON Array Response

I've learned so much using SoapUI, but, I'm just stuck on this one thing. I have the following payload returned:
[
{
"#c": ".CreditPaymentInfo",
"supplementalInfo": null,
"date": "06/30/2015 17:03:50",
"posTxCode": "107535",
"amt": 2.56,
"transactionId": 235087,
"id": 232163,
"cardType": "CREDIT",
"cardHolderName": "SMITH2/JOE",
"expMonthYear": "0119",
"lastFourDigits": "4444",
"approvalCode": "315PNI",
"creditTransactionNumber": "A71A7DB6C2F4"
},
{
"#c": ".CreditPaymentInfo",
"supplementalInfo": null,
"date": "07/01/2015 15:53:29",
"posTxCode": "2097158",
"amt": 58.04,
"transactionId": 235099,
"id": 232176,
"cardType": "CREDIT",
"cardHolderName": "SMITH2/JOE",
"expMonthYear": "0119",
"lastFourDigits": "4444",
"approvalCode": "",
"creditTransactionNumber": null
}
]
I would like to count how many nodes are returned... so, in this case, I would expect that 2 nodes be returned whenever I run this test step in SoapUI.
I was attempting to get this done using the JsonPath Count assertion, but, I just can't see to format it correctly.
Any help would be greatly appreciated!
I have not used JsonPath, but you can do this with XPath ... which works for all older versions too.
Internally SoapUI represents everything as XML. So you could use XPath assertion to check for:
${#ResponseAsXml#count(//*:id)}
and make sure it comes back as
2
Counted successfully with 'JsonPath count' using one of the following (assuming my top level object is an array) :
$
$.
$[*]
If you need to be more specific on the objects you're counting, you can rely only on the 3rd syntax, specifying one of the redundant field. One of the following worked for me :
$[*].fieldName
$[*].['fieldName']
Should return 2 in your case with one of the following :
$[*].#c
$[*].['#c']
$[*].id
$[*].['id']
And so on
This is a JSON format. Just use JsonPath Count. Use $ at the top and 2 at the bottom.
$[index].your.path.here
thus
$[0].date would return "06/30/2015 17:03:50"
and
$[1].date would return "07/01/2015 15:53:29"

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"} }
} );

Resources