The name cannot contain any of the following symbols: '[, ], .'.'. for Compose in Azure Logic App - json

I have below JSON which I need to update inside a logic app
{
"name": "SampleDoc",
"type": "123",
"properties": {
"GP.Test": "M1",
"MG.Test": "C1"
}
}
I have used following setProperty syntax: -
#setProperty(variables('ResponseBody'),'properties', setProperty(variables('ResponseBody')['properties'], 'test','abc'),
setProperty(variables('ResponseBody')['properties'], 'GP.Test','M2'))
My desired JSON output should be
{
"name": "SampleDoc",
"type": "123",
"properties": {
"GP.Test": "M2",
"MG.Test": "C1"
}
}
But when I am running this, I am getting this error: -
InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2617': 'The provided property name 'GP.Test' has these invalid characters '.'. The name cannot contain any of the following symbols: '[, ], .'.'.
Could anyone suggest if we can handle '.' inside compose or any other way for achieving this?

Yes that is correct behavior that is occurring in the logic apps. The reason is that you have used the set property function to set the value of the GP.Test property. When working with the expressions in logic apps, the '.' operator is reserved operator and will be used to access sub properties etc of the expressions, functions etc. Hence you get the error. The solution to this is actually simple, you use the compose action directly without using the set property. Sample screenshot below.
Or if you want complex transformations, then using the liquid transformations through the integration account is the way to go

Related

Expression issues (JSON) with power automate

I'm working on power automate and I have an issue because I've tried a lot expressions and none of them working.
I did a loop (foreach) and inside a message (compose) and there I tried to display "f7626790-0756-43bf-a757-a645a33b853d" from"client"
To do so, I've tried all those expressions:
item()?['client']
item()?['client']?[0]
item()['client']
Here my json file:
[
{
"gift": [
{
"client": "f7626790-0756-43bf-a757-a645a33b853d",
"details": [
{
"client_id": 10859085,
"type": "christmas",
"application_id": "6e6d758d-8e74-3ae3-ac84-50eb23ae65f"
}
]
}
]
}
]
Thank's in advance.
Based on the JSON you provided, you have two arrays. So the question for me is, which array do you want to iterate? Both or the inner one?
I'm going to assume both or if not, it won't matter if you only ever have one item for both of them, my answer will still retrieve the client property.
The Initialize Data step has your JSON.
The Initialize Client step is a blank string at this stage.
The For Each Outer Item expression is simply a link to the Data variable as initialized in the first step.
The For Each Gift expression is set as ... item()?['gift'] ... as you can work out, that will loop over each gift item.
Finally, I get the value of the client property using this expression ... item()['client']

How do I modify parameters in a Container Overrides section of a Step Functions machine?

I have a Step Functions Machine the definition file of which looks as such:
"ContainerOverrides": [
{
"Name": "Foo",
"Environment": [
{
"Name": "Foo"
"Value": "Bar"
},
],
"Command.$": "States.Array($.Foo,$.Foo,$.Bar,$.Bar,$.Bar)"
}
]
},
that I am trying to rewrite into Typescript (CDK). I've gotten the following few lines.
containerOverrides: [{
containerDefinition: Foo,
environment: [
{ name: 'Foo', value: 'Bar'},
],
command: ['States.Array($.Foo,$.Foo,$.Bar,$.Bar,$.Bar)'],
}],
I'm a bit confused about how to go about this.
When I deploy the above CDK code, I get as output:
"Command": [
"States.Array($.Foo,$.Foo,$.Bar,$.Bar,$.Bar)"
],
My confusion is in regards to the following: The ContainerOverrides method doesn't accept parameters, but I need to modify a parameter (Command.$), so how can I possibly do that? I came across this post where somebody seems to have a similar issue, but when I try to apply the proposed solution, of simply writing
command: JsonPath.arrayAt('States.Array($.Foo,$.Foo,$.Bar,$.Bar,$.Bar)'
I get told that ''Cannot use JsonPath fields in an array, they must be used in objects''
TL;DR The current implementation of EcsRunTask doesn't permit this. The general-purpose CallAwsService construct does.
The EcsRunTask construct is the CDK's implementation of the ECS optimised integration. The construct only accepts an array of strings as override commands. It cannot produce substitutable output like "Command.$": "$.commands" that's needed to read the override command from the execution input. This is a limitation of the CDK implementation, not of the ECS optimized integration itself.
The cleanest solution is to use the CallAwsService construct, which implements the SDK service integration. It requires manual configuration. The API-specific config goes in the parameters prop. The prop is loosely typed as { [string]: any }. It's flexible, but it's your job to provide the expected syntax for the ecs:RunTask SDK call. Here is the relevant bit for your question:
parameters {
Overrides: {
ContainerOverrides: [
{ Command: sfn.JsonPath.array("sh", "-c", sfn.JsonPath.stringAt("$.cmd")), },
],
},
}
It produces the expected command override in the Step Functions task definition:
"Command.$": "States.Array('sh', '-c', $.cmd)"

How to get a json value dynamically?

in Jmeter, for the message below i want to get the value of tag CC2650HumidityData (or tag name and tag value) but I don't know the name of tag; it is contained in a variable.
I've used this json path:
$.message.inputData[*].${tagName}
$.message.inputData[*].vars.get("tagName")
but without success.
This is an example of message:
{
"message": {
"inputData": [
{
"CC2650HumidityData": "51",
"dateTime": "2020-12-18T08:35:21.342Z"
},
{
"CC2650BarometricPressureData": "21",
"dateTime": "2020-12-18T08:35:15.136Z"
}
]
}
}
Could you help me?
Your first option, to wit this one: $.message.inputData[*].${tagName} should work just fine
Just make sure that your tagName variable exists and has the anticipated value, it can be done using Debug Sampler and View Results Tree listener combination
Also be aware that you won't be able to use JSONPath Tester mode of the View Results Tree listener for testing JSONPath queries as it doesn't evaluate variables, you will need to run your test to see the variables values (or use this Dummy Sampler like I did)

How to use filter based on rules for IBM Qradar Offenses via REST api?

I'm new to Qradar and facing difficulties in understanding filter parameter in Qradar REST api /siem/offenses. Can anyone suggest me how to use filter based on offense 'rules' field? As rules is a list of JSON objects, i'm finding it difficult to write filter.
sample offense with rules field
{
"username_count": 1,
"description": "String",
"rules": [
{
"id": 1,
"type": "String <one of: ADE_RULE, BUILDING_BLOCK_RULE, CRE_RULE>"
}```
]
}
We experienced a similar issue and find a way out, you can use 'contains' keyword to access list elements. For example, to filter rules[0]["id"] you could use:
rules contains (id = 42)

How to create html table from blob json in Azure Logic App

Hi I would like to create html tabe in Azure Logic App.
I have data loaded from blob via Blob connector (Get blob content using path)
I used Compose connector based on answer in this post
But I get error -
Unable to process template language expressions in action 'Create_HTML_table' inputs at line '1' and column '1747': 'The template language function 'json' parameter is not valid. The provided value '[{"ServiceName":"routingsf","SubServiceName":"roadinfo/supportedmaps","ErrorType":"System.AggregateException","ErrorMessage":"One or more errors occurred. (Object reference not set to an instance of an object.)","Count":4} ]' cannot be parsed: 'Unexpected character encountered while parsing value: . Path '', line 0, position 0.'. Please see https://aka.ms/logicexpressions#json for usage details.'.
Code of Compose and Create HTML table connector is like :
"Compose": {
"inputs": "#base64ToString(body('Get_blob_content_using_path').$content)",
"runAfter": {
"Get_blob_content_using_path_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Create_HTML_table": {
"inputs": {
"format": "HTML",
"from": "#json(outputs('Compose'))"
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Table"
},
Can you help?
Maybe you could try my way to create table. After get the content, use the Parse JSON , the content input json(body('Get_blob_content_using_path')), the Scheme choose Use sample payload to generate schema and just copy and paste your json file content.
Then create HTML table , the From choose the expression array(body('Parse_JSON')).
Here is the Logic flow and my result.
Hope this could help you, if you still have other questions, please let me know.
Update: I copy your json content tomy json file and test again. And It works.
So please make sure you logic app flow is right. Or you could share you flow.
Make sure these two steps are right: