The documentation Combine multiple requests in one HTTP call using JSON batching for sequencing requests with the dependsOn property indicates that not all calls in the sequence needs to be dependent, however, when making the following batch call I receive the error:
BadRequest - Batch should be either fully sequential or fully parallel
'requests': [
{
'id': '1',
'method': 'GET',
'url': '/me/messages?$top=1'
},
{
'id': '2',
'dependsOn': [ '1' ],
'method': 'GET',
'url': '/me/calendar/events?$top=1'
},
{
'id': '3',
'method': 'GET',
'url': 'me/contacts?$top=1'
}
]
You need to add dependsOn to 'id': '3' request too.
Like:
'requests': [
{
'id': '1',
'method': 'GET',
'url': '/me/messages?$top=1'
},
{
'id': '2',
'dependsOn': [ '1' ],
'method': 'GET',
'url': '/me/calendar/events?$top=1'
},
{
'id': '3',
'dependsOn': [ '2' ],
'method': 'GET',
'url': 'me/contacts?$top=1'
}
]
Related
I am trying to show a table in my cloud function using the new #assistant/conversation with the array of data but when i test the action i am getting the error as below
Unsuccessful webhook call: Failed to translate JSON to ExecuteHttpResponse
But when i check the logs i am getting the row values like below
{
"responseJson": {
"session": {
"id": "ABwppHE5M8EGlWf3YmpUUGPQ5xxHh-cb2QYyF_YUarZbF_jXq-Ad2iKDtyI8XAyvWPp4hHnQockBWMZuQA",
"params": {},
"languageCode": ""
},
"prompt": {
"override": false,
"content": {
"table": {
"button": {},
"columns": [
"Date",
"Time",
"Place"
],
"image": {},
"rows": [
"20-10-2020",
"11:20",
"Test"
],
"subtitle": "",
"title": ""
}
}
}
}
}
Here is the implementation of my adding table in the conv
const tempDatas = ['20-10-2020', '11:20', 'Test'];
conv.add(
new Table({
dividers: true,
columns: ['Date', 'Time', 'Place'],
rows: tempDatas
})
);
I have used the same logic in google-actions plugin there it works fine.I have imported the Table like below
const { conversation, Table } = require('#assistant/conversation');
Fixed the issue. The structure provided by the new actions builder is little different with the old one
New Structure:
conv.add(new Table({
'title': 'Table Title',
'subtitle': 'Table Subtitle',
'image': ASSISTANT_LOGO_IMAGE,
'columns': [{
'header': 'Column A',
}, {
'header': 'Column B',
}, {
'header': 'Column C',
}],
'rows': [{
'cells': [{
'text': 'A1',
}, {
'text': 'B1',
}, {
'text': 'C1',
}],
}, {
'cells': [{
'text': 'A2',
}, {
'text': 'B2',
}, {
'text': 'C2',
}],
}, {
'cells': [{
'text': 'A3',
}, {
'text': 'B3',
}, {
'text': 'C3',
}],
}],
}));
You can simplify it like below that is the solution for my above issue
const tableRows = [];
tablesRows.push({ 'cells': [{ 'text': moment(data.date).format('DD-MM-YYYY') }, { 'text': data.time }, { 'text': data.place }] });
conv.add(new Table({
'columns': [{
'header': 'Date',
}, {
'header': 'Time',
}, {
'header': 'Place',
}],
'rows': tablesRows,
}));
For more info visit conversation components
When requesting GET https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events the response (for some events) does not have a Start and End date.
The full structure for such events is as follows:
{
'OriginalStartTimeZone': None,
'End': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'HasAttachments': False,
'ResponseRequested': True,
'ShowAs': 'Free',
'Recurrence': None,
'Start': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'BodyPreview': '',
'AllowNewTimeProposals': True,
'Location': {...},
'Attendees': [...],
'TransactionId': None,
'Type': 'SingleInstance',
'ResponseStatus': {
'Response': 'NotResponded',
'Time': '0001-01-01T00:00:00Z'
},
'Body': {...},
'OnlineMeeting': None,
'IsRoomRequested': False,
'OnlineMeetingProvider': 'Unknown',
'IsCancelled': False,
'IsAllDay': False,
'ReminderMinutesBeforeStart': 0,
'Subject': '...',
'Categories': [],
'LastModifiedDateTime': '2020-03-11T18:31:15.548Z',
'AutoRoomBookingOptions': None,
'OriginalEndTimeZone': None,
'CreatedDateTime': '2020-03-11T18:34:34.259429Z',
'IsOnlineMeeting': False,
'#odata.id': '...',
'IsDraft': False,
'WebLink': '...',
'ChangeKey': '...',
'SeriesMasterId': None,
'IsOrganizer': True,
'iCalUId': None,
'AutoRoomBookingStatus': 'None',
'Locations': [],
'Id': '...',
'IsReminderOn': False,
'Calendar#odata.associationLink': '...',
'Calendar#odata.navigationLink': '...',
'Importance': 'Normal',
'Organizer': {...},
'#odata.etag': '...',
'Sensitivity': 'Normal',
'OnlineMeetingUrl': None
}
Is this normal behavior? If so, how can this be displayed?
How can I create such an event to reproduce it?
I got the following List<Map> in Flutter:
List<Map<String, dynamic>> recipeList = [
{
'name': 'rec1',
'id': 1,
'img': 'images/recipe.jpg',
'ingredients': [{
'name': 'salt',
'amount': '1',
'unit': '1',
},
{
'name': 'flour',
'amount': '100',
'unit': 'g',
},
{
'name': 'water',
'amount': '100',
'unit': 'g',
},
{
'name': 'milk',
'amount': '100',
'unit': 'g',
},],
},]
I pass it down through several Widgets and at some point I want to add the key value pair {'didBuy':false} to every Map inside the ingredients list (which is basically recipeList['ingredients']).
Thus I call:
List<Map<String, dynamic>> resultList = recipeList['ingredients'].map((elem) {
elem.addAll({'didBuy': false});
print(elem);
}).toList();
Unfortunately the following error message results: Dart Error: Unhandled exception:type '_InternalLinkedHashMap<String, bool>' is not a subtype of type 'Map<String, String>' of 'other'.
Does anybody know what is the correct way to add something to a map, without getting this error message?
Edited the question to be more precise.
EDIT2:
After calling the type of the List explicitly inside the Map as Hadrien suggested, I can add the key value pair with the boolean. Long term I want to fetch the data from the Internet, so I defined a RecipeObj:
class RecipeObj{
String name;
int id;
String img;
List<Map<String, dynamic>> ingredients;
RecipeObj(this.name, this.id, this.img, this.ingredients);
}
Here I explicitly state the type of the ingredients attribute, so I thought I could get of the explicit calling inside the (main) recipeList. But after passing the ingredients attribute down through some widgets, flutter recognizes it as List<Map<String, String>>, although I define it everywhere as an List<Map<String, dynamic>>, why is that?
dart infer the type of your ingredients list with Map<String, String>
you can specify the type by yourself inside your list
'ingredients': <Map<String, dynamic>>[ {
'name': 'salt',
'amount': '1',
'unit': '1',
},
or build a new Map<String, dynamic> inside your map function
List<Map<String, dynamic>> resultList = recipeList['ingredients'].map((elem) {
final map = Map<String, dynamic>.from(elem);
map.addAll({'didBuy': false});
return map;
}).toList();
This should do
List<Map<String,dynamic>> recipeList = [
at least if recipeList and ingredients point at the same collection instance.
var ingredients = recipeList;
Is this what you need?
void main() {
List<Map> recipeList = [
{
'name': 'rec1',
'id': 1,
'img': 'images/recipe.jpg',
'ingredients': [{
'name': 'salt',
'amount': '1',
'unit': '1',
},
{
'name': 'flour',
'amount': '100',
'unit': 'g',
},
{
'name': 'water',
'amount': '100',
'unit': 'g',
},
{
'name': 'milk',
'amount': '100',
'unit': 'g',
},]
},];
print("[DATA BEFORE ANY CHANGE]");
print("recipeList.length=${recipeList.length}");
print("recipeList[0][\"ingredients\"]=${recipeList[0]["ingredients"]}");
print("recipeList[0][\"ingredients\"].last=${recipeList[0]["ingredients"].last}");
print("recipeList[0][\"ingredients\"].length=${recipeList[0]["ingredients"].length}");
// no recipe is worth if it doesn't contain chocolate
recipeList[0]["ingredients"].add({
'name': 'cocoa powder',
'amount': '200',
'unit': 'g',
});
print("\n\n[DATA AFTER ADD]");
print("recipeList[0][\"ingredients\"].last=${recipeList[0]["ingredients"].last}");
print("recipeList[0][\"ingredients\"].length=${recipeList[0]["ingredients"].length}");
}
OUTPUT
[DATA BEFORE ANY CHANGE]
recipeList.length=1
recipeList[0]["ingredients"]=[{name: salt, amount: 1, unit: 1}, {name: flour, amount: 100, unit: g}, {name: water, amount: 100, unit: g}, {name: milk, amount: 100, unit: g}]
recipeList[0]["ingredients"].last={name: milk, amount: 100, unit: g}
recipeList[0]["ingredients"].length=4
[DATA AFTER ADD]
recipeList[0]["ingredients"].last={name: cocoa powder, amount: 200, unit: g}
recipeList[0]["ingredients"].length=5
Not sure exactly how to ask this as I am learning as I go. I am creating/updating user information from my app to a third party CRM system.
I have two methods that run successfully with an after_save callback. During testing, I would comment one out so I can test the other but now I need to combine them with an if else statement.
What should happen when combined together is when User is saved, the system will see if a user exists on the CRM system - if agile_id?. If user exists, it will skip down to the update call and send over any updated contact data, but if it doesn't, it will create a new CRM contact record.
The error I am receiving in the browser is:
undefined method `agile_id?' for #<User:0x007ffe24cef318>
user.rb
...
after_save :sync_to_agilecrm
...
def sync_to_agilecrm
agile_id = AgileCRM.request :get, 'contacts/search/email/'+email, nil
if agile_id?
contact_data = {
'properties': [
{ 'type': 'SYSTEM', 'name': 'first_name', 'value': first_name },
{ 'type': 'SYSTEM', 'name': 'last_name', 'value': last_name },
{ 'type': 'SYSTEM', 'name': 'email', 'subtype': 'work', 'value': email },
{ 'type': 'SYSTEM', 'name': 'address', 'value': '{\"address\":\"225 George Street\",\"city\":\"NSW\",\"state\":\"Sydney\",\"zip\":\"2000\",\"country\":\"Australia\"}' },
]
}
parsed_contact_data = JSON.parse(contact_data.to_json)
print(AgileCRM.request :post, 'contacts', parsed_contact_data)
else
update_contact_data = {
'id': agile_id,
'properties': [
{ 'type': 'SYSTEM', 'name': 'first_name', 'value': first_name },
{ 'type': 'SYSTEM', 'name': 'last_name', 'value': last_name },
{ 'type': 'SYSTEM', 'name': 'email', 'subtype': 'work', 'value': email },
{ 'type': 'SYSTEM', 'name': 'address', 'subtype': 'work', 'value': address_line1 },
]
}
parsed_update_contact_data = JSON.parse(update_contact_data.to_json)
print(AgileCRM.request :put, 'contacts/edit-properties', parsed_update_contact_data)
end
end
...
agile_id and agile_id? aren't the same thing. You'll sometimes see ActiveRecord objects which have record.attribute? which is enabled through some meta programming.
So, when defining a variable such as agile_id, adding a question mark on the end won't just work, nor is it needed. a simple if agile_id should be sufficient.
I have the following simple swagger.json file. This is generated using go-swagger annotations for a golang service. I am able to get the UI page running with redoc.
I want to display it with swagger-ui but I cannot get it to work. It shows an error in console on the page load that says
Uncaught TypeError: Cannot create property 'definitions' on string 'swagger.json'(…)
window.swaggerUi = new SwaggerUi({
spec: "swagger.json",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded UI")
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false
});
window.swaggerUi.load();
Not sure why that is happening
The redoc page displays as follows
This is the swagger file
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "the purpose of this service is to do a health check",
"title": "Health Check API.",
"termsOfService": "TOS",
"contact": {
"name": "Backend",
"email": "Backend#company.com"
},
"license": {
"name": "Company Licence"
},
"version": "0.0.1"
},
"host": "host.com",
"basePath": "/",
"paths": {
"/health": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"summary": "Health check route.",
"operationId": "health",
"responses": {}
}
}
},
"definitions": {}
}
From SwaggerUI docs, it seems that it expects
A JSON object describing the OpenAPI Specification
as a value of spec parameter.
You should use url if you want to provide it with url:
window.swaggerUi = new SwaggerUi({
url: "swagger.json", // <----------------- change to url here
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded UI")
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false
});
window.swaggerUi.load();