How can I get some specific values from a JObject - c#

I want to get the FILE-file-id, FILE-fileSize FILENAME-id, INCIDENT-reportedOn out of the following JObject:
Note the two "[[" at the beginning. Do I have to reduce the JObject first?
[
[{
"FILENAME": {
"id": "renamedtopdf.docx.pdf",
"label": "fileName",
"type": "vertex"
},
"FILE": {
"id": "dc92d48b7e29c528b3eb168446e51736101122a821c9e712320bd6842116719a",
"label": "file",
"type": "vertex",
"properties": {
"fileSize": [{
"id": "f9339436-189a-4503-abc6-e2989be6f138",
"value": "164198"
}],
"mimeType": [{
"id": "0a89dbfa-c204-45c8-8524-3fbd02b04e39",
"value": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
}]
}
},
"INCIDENT": {
"id": "16ea8c8b-65ee-44b3-afbb-98308b092b4f",
"label": "incident",
"type": "vertex",
"properties": {
"reportedOn": [{
"id": "81485296-a62f-4d17-a03f-4995c3cad937",
"value": "2/16/2019 10:33:59 AM"
}]
}
}
},

I'll assume you already extracted the JObject from the two arrays. I that case you can simply use the index operator to traverse the json file like so:
json["FILE"]["id"].Value<string>();
json["FILE"]["properties"]["fileSize"]["value"].Value<string>();
json["FILENAME"]["id"].Value<string>();
json["INCIDENT"]["properties"]["reportedOn"]["Value"].Value<string>();
Full Example:
const string text = #"{
"FILENAME": {
"id": "renamedtopdf.docx.pdf",
"label": "fileName",
"type": "vertex"
},
"FILE": {
"id": "dc92d48b7e29c528b3eb168446e51736101122a821c9e712320bd6842116719a",
"label": "file",
"type": "vertex",
"properties": {
"fileSize": [
{
"id": "f9339436-189a-4503-abc6-e2989be6f138",
"value": "164198"
}
],
"mimeType": [
{
"id": "0a89dbfa-c204-45c8-8524-3fbd02b04e39",
"value": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
}
]
}
},
"INCIDENT": {
"id": "16ea8c8b-65ee-44b3-afbb-98308b092b4f",
"label": "incident",
"type": "vertex",
"properties": {
"reportedOn": [
{
"id": "81485296-a62f-4d17-a03f-4995c3cad937",
"value": "2/16/2019 10:33:59 AM"
}
]
}
}
}";
var json = JObject.Parse(text);
json["FILE"]["id"].Value<string>();
json["FILE"]["properties"]["fileSize"]["value"].Value<string>();
json["FILENAME"]["id"].Value<string>();
json["INCIDENT"]["properties"]["reportedOn"]["Value"].Value<string>();

Related

How to validate Json With schema C#

I am trying to validate JSON (API response) with a JSON schema with
string data = File.ReadAllText(#"C:\Users\Aman.Sharma\Source\Repos\Validator\Validator\testData.json");
string schema = File.ReadAllText(#"C:\Users\Aman.Sharma\Source\Repos\Validator\Validator\V2JsonSchema.json");
var model = JObject.Parse(data);
var json_schema = JSchema.Parse(schema);
bool valid = model.IsValid(json_schema, out IList<string> messages);
But the problem just throws an error with the first occurrence of error and skips the other part.
Is there any way to compare the whole JSON with schema and throw errors for each record?
Also this method If I change the schema always pass the JSON.
Sample Data
{
"id": "e1110047-b606-4fb3-84c6-28f7d5456e11",
"accountInactiveDate": "0001-01-01T00:00:00Z",
"accountOpenDate": "0001-01-01T00:00:00Z",
"accountTypeIds": [ 4000 ],
"address": {
"city": "vVjEKwUP",
"addressTypeId": 1000,
"countryISOCode": "GBR",
"street1": "xTMksdLL",
"zipCode": "12345"
},
"annualRevenue": 0.0,
"email": {
"emailTypeId": 1000,
"email": "zvvzwsdv#yopmail.com"
},
"homeLocationNumber": "316",
"industryTypeId": 0,
"isDeleted": false,
"name": "AccounttxecJizQ",
"parentAccountId": "00000000-0000-0000-0000-000000000000",
"phone": {
"phoneTypeId": 1000,
"number": "+44 123456"
},
"productsTypeIds": [ 3000 ],
"timeStamp": "\"2e001932-0000-0d00-0000-63315d8e0000\"",
"links": [
{
"href": "https://api-test.QA.cloud/companies/api/v2/accounts/e1110047-b606-4fb3-84c6-28f7d5456e11",
"rel": "Self"
}
],
"isBlocked": false,
"isComplete": true,
"createDate": "2022-09-26T08:06:38.2263447Z",
"systemCaller": "qa-user2-automationtests",
"originSystemCaller": "qa-user2-automationtests",
"originCreateDate": "2022-09-26T08:06:38.2263447Z"
}
Schema
{
"type": "object",
"properties": {
"searchMode": {
"enum": [
"Any",
"All"
],
"type": "string"
},
"queryType": {
"enum": [
"Simple",
"Full"
],
"type": "string"
},
"select": {
"type": "array",
"items": {
"type": "string"
}
},
"searchFields": {
"type": "array",
"items": {
"type": "string"
}
},
"orderBy": {
"type": "array",
"items": {
"type": "string"
}
},
"highlightPreTag": {
"type": "string"
},
"highlightPostTag": {
"type": "string"
},
"highlightFields": {
"type": "array",
"items": {
"type": "string"
}
},
"filter": {
"type": "string"
},
"facets": {
"type": "array",
"items": {
"type": "string"
}
},
"scoringProfile": {
"type": "string"
},
"scoringParameters": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"page": {
"format": "int32",
"type": "integer"
},
"pageSize": {
"format": "int32",
"type": "integer"
},
"includeTotalResultCount": {
"type": "boolean"
}
}
}
I had similar errors with such approach.
Try add .Replace("\r", "").Replace("\n", "") at the end of code that reads data from files.
If it works - replace with less rude approach of ignoring of \r and \n.

Parse an adaptive card json to C# object and dynamically build Action.Showcards based on my api data

I have an adaptive card json with Action.ShowCard property and 1 submit button. I want to convert it to C# object and loop the Action.showcard to dynamically build multiple showcard buttons based on the count/data coming from an api call.
I was able to convert it to c# object using "AdaptiveCard.FromJson(json).Card", but not able to proceed further
Suppose i get 3 project codes, so i want to build 3 action.showcards and populate its fields from api data.
Below is the adaptive card with only 1 showcard, I need to consume this card and build multiple showcards.
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"text": "**Timesheet Project Codes**",
"wrap": true
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.ShowCard",
"title": "123456",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Code:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "123456",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Name:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "abc/def/ghi",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Cost Code:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "ghi1234",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Code Start Date:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "January 1, 2022",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Code End Date: ",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "December 31, 2025",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Code Allocation Start Date:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "March 1, 2022",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Project Code Allocation End Date:",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "November 31, 2022",
"wrap": true
}
]
}
]
}
]
}
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Fill Timesheet",
"data": "Fill Timesheet"
}
]
}
]
}
From your explanation, I understand that you're using AdaptiveCard.FromJson to deserialize the entire thing into onc card.
Instead, you could try deserializing the JSON and then parsing it to build multiple separate Adaptive Cards in code.
Once you have built C# objects from your parsed JSON, you can then manipulate them and add or remove components as desired.

Is it possible to convert HttpResponseMessage json to object?

need to mock the HttpResponseMessage in my Unit Test.
using .net core 3.1/
getting the following error:
Newtonsoft.Json.JsonSerializationException : Could not create an
instance of type System.Net.Http.HttpContent. Type is an interface or
abstract class and cannot be instantiated. Path
'httpResponseMessage.Content.Headers', line 206, position 16.
Deserialize Code:
public static T GetObjectFromFile<T>(string fileName) where T : class
{
var directory = AppDomain.CurrentDomain.BaseDirectory;
var path = string.Format("{0}\\Stubs\\{1}", directory, fileName);
string stubContent = System.IO.File.ReadAllText(path);
T res = JsonConvert.DeserializeObject<T>(stubContent, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new PrivateResolver(),
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
});
return res;
}
T is (for the example):
public class ResponseWithHttpResponseMessage
{
public HttpResponseMessage HttpResponseMessage { get; set; }
}
JSON example:
{
"HttpResponseMessage": {
"Version": "1.1",
"Content": {
"Headers": [
{
"Key": "Content-Type",
"Value": [ "application/json" ]
}
]
},
"StatusCode": 200,
"ReasonPhrase": "OK",
"Headers": [
{
"Key": "X-Backside-Transport",
"Value": [ "OK OK,FAIL FAIL,OK OK" ]
},
{
"Key": "Connection",
"Value": [ "Keep-Alive" ]
},
{
"Key": "Transfer-Encoding",
"Value": [ "chunked" ]
},
{
"Key": "Date",
"Value": [ "Wed, 23 Dec 2020 14:04:56 GMT" ]
},
{
"Key": "X-Global-Transaction-ID",
"Value": [ "1fd23d895fe34e870c0158c2" ]
},
{
"Key": "User-Agent",
"Value": [ "IBM-APIConnect/5.0" ]
},
{
"Key": "Access-Control-Expose-Headers",
"Value": [ "APIm-Debug-Trans-Id, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-Global-Transaction-ID" ]
},
{
"Key": "Access-Control-Allow-Origin",
"Value": [ "*" ]
},
{
"Key": "Access-Control-Allow-Methods",
"Value": [ "GET" ]
},
{
"Key": "X-RateLimit-Limit",
"Value": [ "name=rate-limit,92;" ]
},
{
"Key": "X-RateLimit-Remaining",
"Value": [ "name=rate-limit,81;" ]
}
],
"TrailingHeaders": [],
"RequestMessage": {
"Version": "1.1",
"Content": null,
"Method": { "Method": "GET" },
"RequestUri": "https://EXAMLE?F=I,C,",
"Headers": [
{
"Key": "M-ID",
"Value": [ "1" ]
}
],
"Properties": {}
},
"IsSuccessStatusCode": true
}
}
seems that the headers class is sealed and therefore it is not possible to mock it.
but is there any chance that a workaround is exist?

Find values in dynamic JSON results

I am looking for a script to find the value of $6383.12 for Accounts Receivable (A/R) in this code. There are several values I want to be able to find but I can't seem to figure out how to structure my code to find the values I need.
I have spent time looking through and testing various versions of arrays, ILIst<> and other suggestions but I can't seem to get the final result I am looking for. I can find a single value (for example "Savings") but I don't know how to get the $800 value.
The script I am using is:
var root = JToken.Parse(data);
IList<JToken> t = root.SelectTokens("$...ColData[?(#.value == 'Accounts Receivable (A/R)')]").ToList();
foreach (var item in t)
{
Response.Write(item.ToString() + "<br/><br/>");
}
This gives me the Accounts Receivable (A/R) value but not the dollar value associated with it.
Here is the JSON result I am trying to parse through:
{
"Header": {
"ReportName": "BalanceSheet",
"Option": [
{
"Name": "AccountingStandard",
"Value": "GAAP"
},
{
"Name": "NoReportData",
"Value": "false"
}
],
"DateMacro": "this calendar year-to-date",
"ReportBasis": "Accrual",
"StartPeriod": "2016-01-01",
"Currency": "USD",
"EndPeriod": "2016-10-31",
"Time": "2016-10-31T09:42:21-07:00",
"SummarizeColumnsBy": "Total"
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "ASSETS"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "Current Assets"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "Bank Accounts"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "35",
"value": "Checking"
},
{
"value": "1350.55"
}
],
"type": "Data"
},
{
"ColData": [
{
"id": "36",
"value": "Savings"
},
{
"value": "800.00"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "BankAccounts",
"Summary": {
"ColData": [
{
"value": "Total Bank Accounts"
},
{
"value": "2150.55"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Accounts Receivable"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "84",
"value": "Accounts Receivable (A/R)"
},
{
"value": "6383.12"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "AR",
"Summary": {
"ColData": [
{
"value": "Total Accounts Receivable"
},
{
"value": "6383.12"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Other current assets"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "81",
"value": "Inventory Asset"
},
{
"value": "596.25"
}
],
"type": "Data"
},
{
"ColData": [
{
"id": "4",
"value": "Undeposited Funds"
},
{
"value": "2117.52"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "OtherCurrentAssets",
"Summary": {
"ColData": [
{
"value": "Total Other current assets"
},
{
"value": "2713.77"
}
]
}
}
]
},
"type": "Section",
"group": "CurrentAssets",
"Summary": {
"ColData": [
{
"value": "Total Current Assets"
},
{
"value": "11247.44"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Fixed Assets"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"id": "37",
"value": "Truck"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "38",
"value": "Original Cost"
},
{
"value": "13495.00"
}
],
"type": "Data"
}
]
},
"type": "Section",
"Summary": {
"ColData": [
{
"value": "Total Truck"
},
{
"value": "13495.00"
}
]
}
}
]
},
"type": "Section",
"group": "FixedAssets",
"Summary": {
"ColData": [
{
"value": "Total Fixed Assets"
},
{
"value": "13495.00"
}
]
}
}
]
},
"type": "Section",
"group": "TotalAssets",
"Summary": {
"ColData": [
{
"value": "TOTAL ASSETS"
},
{
"value": "24742.44"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "LIABILITIES AND EQUITY"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "Liabilities"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "Current Liabilities"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"Header": {
"ColData": [
{
"value": "Accounts Payable"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "33",
"value": "Accounts Payable (A/P)"
},
{
"value": "1984.17"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "AP",
"Summary": {
"ColData": [
{
"value": "Total Accounts Payable"
},
{
"value": "1984.17"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Credit Cards"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "41",
"value": "Mastercard"
},
{
"value": "157.72"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "CreditCards",
"Summary": {
"ColData": [
{
"value": "Total Credit Cards"
},
{
"value": "157.72"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Other Current Liabilities"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "89",
"value": "Arizona Dept. of Revenue Payable"
},
{
"value": "4.55"
}
],
"type": "Data"
},
{
"ColData": [
{
"id": "90",
"value": "Board of Equalization Payable"
},
{
"value": "401.98"
}
],
"type": "Data"
},
{
"ColData": [
{
"id": "43",
"value": "Loan Payable"
},
{
"value": "4000.00"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "OtherCurrentLiabilities",
"Summary": {
"ColData": [
{
"value": "Total Other Current Liabilities"
},
{
"value": "4406.53"
}
]
}
}
]
},
"type": "Section",
"group": "CurrentLiabilities",
"Summary": {
"ColData": [
{
"value": "Total Current Liabilities"
},
{
"value": "6548.42"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Long-Term Liabilities"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "44",
"value": "Notes Payable"
},
{
"value": "25000.00"
}
],
"type": "Data"
}
]
},
"type": "Section",
"group": "LongTermLiabilities",
"Summary": {
"ColData": [
{
"value": "Total Long-Term Liabilities"
},
{
"value": "25000.00"
}
]
}
}
]
},
"type": "Section",
"group": "Liabilities",
"Summary": {
"ColData": [
{
"value": "Total Liabilities"
},
{
"value": "31548.42"
}
]
}
},
{
"Header": {
"ColData": [
{
"value": "Equity"
},
{
"value": ""
}
]
},
"Rows": {
"Row": [
{
"ColData": [
{
"id": "34",
"value": "Opening Balance Equity"
},
{
"value": "-9337.50"
}
],
"type": "Data"
},
{
"ColData": [
{
"id": "2",
"value": "Retained Earnings"
},
{
"value": "91.25"
}
],
"type": "Data"
},
{
"ColData": [
{
"value": "Net Income"
},
{
"value": "2440.27"
}
],
"type": "Data",
"group": "NetIncome"
}
]
},
"type": "Section",
"group": "Equity",
"Summary": {
"ColData": [
{
"value": "Total Equity"
},
{
"value": "-6805.98"
}
]
}
}
]
},
"type": "Section",
"group": "TotalLiabilitiesAndEquity",
"Summary": {
"ColData": [
{
"value": "TOTAL LIABILITIES AND EQUITY"
},
{
"value": "24742.44"
}
]
}
}
]
},
"Columns": {
"Column": [
{
"ColType": "Account",
"ColTitle": "",
"MetaData": [
{
"Name": "ColKey",
"Value": "account"
}
]
},
{
"ColType": "Money",
"ColTitle": "Total",
"MetaData": [
{
"Name": "ColKey",
"Value": "total"
}
]
}
]
}
}
You can try this,
var json = File.ReadAllText("json1.json");
var jToken = JToken.Parse(json);
var reader = jToken.CreateReader();
while (reader.Read())
{
var value = reader.Value;
if (value != null && value.ToString() == "Accounts Receivable (A/R)")
{
var test = jToken.SelectToken(reader.Path.Replace("[0].value", "[1].value"));
}
}
If it's not doable to write json path which selects proper tokens you could try using Parent property and Children method.
foreach (var item in t)
{
var valueToken = item.Parent.Children().ElementAt(1);
Response.Write(valueToken.ToString() + "<br/><br/>");
}

Adaptive Cards C# - How to add Action.Submit within the Body ColumnSet (Each Row)

I am trying to display an Adaptive Card in the BOT DirectLine Chat. The Adaptive card will contain the data in a table format. I want to add Action button on each row of the table to perform a particular operation.
But I am not able to add the 'Action.Submit' within the ColumnSet. I am only able to add outside of the body section (i.e., separate action section).
Please help me on this. Below is the Sample JSON send to the Directline client.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Pending Items",
"weight": "bolder",
"size": "medium"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Number",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Module",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Pending count",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Action",
"weight": "bolder",
"wrap": true
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "1",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Module 1",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "1",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Input.Toggle",
"id": "acceptTerms",
"title": "Select this",
"value": "true",
"valueOn": "true",
"valueOff": "false"
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "2",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Module 1",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "10",
"weight": "bolder",
"wrap": true
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Input.Toggle",
"id": "acceptTerms",
"title": "Select this",
"value": "true",
"valueOn": "true",
"valueOff": "false"
}
]
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Proceed Selected",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Are you sure want to Proceed",
"weight": "bolder",
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
},
{
"type": "Action.Submit",
"title": "Cancel",
"id": "c1"
}
]
}
You can place a Container inside a column.
This example can show without errors an action inside columns:
It is tested in this Adaptive Card Designer
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body":[
{
"type": "TextBlock",
"size": "Small",
"text": "You have the following Time Off planned:"
}, {
"type": "ColumnSet",
"columns": [{
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "Holiday"
}]
}, {
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "-"
}]
}, {
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "Approved"
}]
}, {
"type": "Column",
"width": "stretch",
"items": [{
"type": "Container",
"items": [{
"type": "ActionSet",
"actions": [{
"type": "Action.Submit",
"title": "Cancel",
"data": {
"action": "cancelRequest"
}
}]
}]
}]
}]
}, {
"type": "ColumnSet",
"columns": [{
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "from "
}]
}, {
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "2019-09-11"
}]
}, {
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "to "
}]
}, {
"type": "Column",
"width": "auto",
"items": [{
"type": "TextBlock",
"size": "Small",
"text": "2019-09-18"
}]
}]
}],
"actions": [{
"type": "Action.Submit",
"title": "Submit New Request",
"data": {
"action": "timeoff.request.card"
}
}, {
"type": "Action.Submit",
"title": "Dismiss",
"data": {
"action": "timeoff.cancel"
}
}]
}

Categories

Resources