How to Declare Authorizations HTTP POST msteam? - http-post

I have try completed input text then post to webhook.
below code :
{
"#type": "MessageCard",
"#context": "",
"themeColor": "0076D7",
"summary": "Larry Bryant created a new task",
"sections": [{
"activityTitle": "![TestImage]()Larry Bryant created a new task",
"activitySubtitle": "On Project Tango",
"activityImage": "image5.png",
"facts": [{
"name": "Assigned to",
"value": "Unassigned"
}, {
"name": "Due date",
"value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
}, {
"name": "Status",
"value": "Not started"
}],
"markdown": true
}],
"potentialAction": [{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [{
"#type": "TextInput",
"id": "comment",
"isMultiline": false,
"title": "Add a comment here for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Send mail",
"target": "webhook/######",
"body": "{'text':''}"
}]
}]
}
but i tried with my api then send mail with authorizations in headers.
below code :
POST webhook/######
Content-Type: application/json
{
"#type": "MessageCard",
"#context": "/extensions",
"themeColor": "0076D7",
"summary": "Larry Bryant created a new task",
"sections": [{
"activityTitle": "![TestImage](/default.png)Larry Bryant created a new task",
"activitySubtitle": "On Project Tango",
"activityImage": "img/image5.png",
"facts": [{
"name": "Assigned to",
"value": "Unassigned"
}, {
"name": "Due date",
"value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
}, {
"name": "Status",
"value": "Not started"
}],
"markdown": true
}],
"potentialAction": [{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [{
"#type": "TextInput",
"id": "comment",
"isMultiline": false,
"title": "Add a comment here for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Send mail",
"target": "domain.com/api/sendmail",
"headers": [
{"Authorization": "Bearer token#####"},
{"Content-Type": "application/json"},
],
"body": "{
'subjects':'Title Mail',
'message':'Hello World',
'recipient_list':'email#mail.com',
'bcc':'email#mail.com'
}"
}]
}]
}
Send to msteam completed when i click button then send json to api this is my message error
Thanks for your support . have fun today
The remote endpoint returned an error (HTTP Unauthorized). Please try again later.

Related

Is there any scope for MS Teams message extension to work in Team's channel (private + public)?

MS Teams message extension is working in bot personal chats and default team of tenant but not working in others team's channels.
I'm getting error:
Error
This is manifest file for my app:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0",
"id": "<<id>>",
"packageName": "com.microsoft.teams.samples",
"developer": {
"name": "Microsoft",
"websiteUrl": "https://dev.botframework.com",
"privacyUrl": "https://privacy.microsoft.com",
"termsOfUseUrl": "https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default.aspx"
},
"icons": {
"color": "icon-color.png",
"outline": "icon-outline.png"
},
"name": {
"short": "Demo",
"full": "Demo Demo"
},
"description": {
"short": "Sample demonstrating an Action Based Messaging Extension with Preview",
"full": "Sample Action Messaging Extension built with the Bot Builder SDK demonstrating Preview"
},
"accentColor": "#FFFFFF",
"bots": [
{
"botId": "<<botId>>",
"scopes": [
"personal",
"team",
"groupchat"
]
}
],
"composeExtensions": [
{
"botId": "<<botId>>",
"canUpdateConfiguration": false,
"commands": [
{
"id": "create",
"type": "action",
"title": "Create",
"description": "Create new card",
"initialRun": false,
"fetchTask": false,
"context": [
"compose"
],
"parameters": [
{
"name": "description",
"title": "Title",
"description": "Enter Title...",
"inputType": "textarea"
}
]
}
]
}
],
"validDomains": []
}
I have seen others apps are able to send message from message extension without installing it to particular teams.

Category is missing from outlook event from the notification

I had set up graph client notification for event updates, when I add a category to an existing event, the updated event from notification is missing the applied category sometimes. I tried to get the event at some intervals and found out that the category does show up but there is no definite time delay, does anyone know what could be the max delay or any technique to get the category immediately?
Code used to subscribe for notifications.
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "created,updated",
"notificationUrl": "https://webhook.azurewebsites.net/notificationClient",
"resource": "/users/{userId}/mailfolders('inbox')/events",
"expirationDateTime": "2016-03-20T11:00:00.0000000Z",
"clientState": "abcd"
}
Received notification on updating an event (Added a new category to event)
{
"changeType": "updated",
"clientState": "abc",
"resource": "Users/{UserId}/Events/AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQBGAAAAAACcxCFvSYx4Qq2TvvDk7ptoBwApGtasXg2jRLv-yfVbSS5rAAAAAAENAAApGtasXg2jRLv-yfVbSS5rAAE3GB9UAAA=",
"subscriptionExpirationDateTime": "2022-02-09T00:07:27.333244-08:00",
"subscriptionId": "00508233-d60c-4905-8c4f-cb101a43f8c1",
"resourceData": {
"id": "AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQBGAAAAAACcxCFvSYx4Qq2TvvDk7ptoBwApGtasXg2jRLv-yfVbSS5rAAAAAAENAAApGtasXg2jRLv-yfVbSS5rAAE3GB9UAAA=",
"#odata.etag": "W/\"DwAAABYAAAApGtasXg2jRLv/yfVbSS5rAAE4W5d/\"",
"#odata.id": "Users/bfc9acdc-7ae7-4cbe-af4f-843acd8945d8/Events/AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQBGAAAAAACcxCFvSYx4Qq2TvvDk7ptoBwApGtasXg2jRLv-yfVbSS5rAAAAAAENAAApGtasXg2jRLv-yfVbSS5rAAE3GB9UAAA=",
"#odata.type": "#Microsoft.Graph.Event"
}
}
When I tried to get the event from graph client the category was missing in the category list
{
"allowNewTimeProposals": true,
"attendees": [],
"body": {
"content": "",
"contentType": "html",
"#odata.type": "microsoft.graph.itemBody"
},
"bodyPreview": "",
"end": {
"dateTime": "2022-01-23T03:30:00.0000000",
"timeZone": "UTC",
"#odata.type": "microsoft.graph.dateTimeTimeZone"
},
"hasAttachments": false,
"hideAttendees": false,
"iCalUId": "040000008200E00074C5B7101A82E00800000000FA8C485E1718D8010000000000000000100000002019A4F391D06D40B7A90ACC0E408951",
"importance": "normal",
"isAllDay": false,
"isCancelled": false,
"isDraft": false,
"isOnlineMeeting": false,
"isOrganizer": true,
"isReminderOn": true,
"location": {
"displayName": "ABCD",
"locationType": "default",
"uniqueId": "ABCD",
"uniqueIdType": "private",
"#odata.type": "microsoft.graph.location"
},
"locations": [
{
"displayName": "ABCD",
"locationType": "default",
"uniqueId": "ABCD",
"uniqueIdType": "private",
"#odata.type": "microsoft.graph.location"
}
],
"onlineMeetingProvider": "unknown",
"organizer": {
"emailAddress": {
"address": "{userEmail}",
"name": "{Name}",
"#odata.type": "microsoft.graph.emailAddress"
},
"#odata.type": "microsoft.graph.recipient"
},
"originalEndTimeZone": "Sri Lanka Standard Time",
"originalStartTimeZone": "Sri Lanka Standard Time",
"reminderMinutesBeforeStart": 15,
"responseRequested": true,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00+00:00",
"#odata.type": "microsoft.graph.responseStatus"
},
"sensitivity": "normal",
"showAs": "busy",
"start": {
"dateTime": "2022-01-23T03:00:00.0000000",
"timeZone": "UTC",
"#odata.type": "microsoft.graph.dateTimeTimeZone"
},
"subject": "Test1234",
"transactionId": "BFA967CF-A111-5A49-8564-C74031DEA04B_6F9F0BA5-05C8-465F-9B56-5E3318BFF06B_343",
"type": "singleInstance",
"webLink": "https://outlook.office365.com/owa/?itemid=AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQBGAAAAAACcxCFvSYx4Qq2TvvDk7ptoBwApGtasXg2jRLv%2FyfVbSS5rAAAAAAENAAApGtasXg2jRLv%2FyfVbSS5rAAE0tLDTAAA%3D&exvsurl=1&path=/calendar/item",
"categories": [],
"changeKey": "KRrWrF4No0S7/8n1W0kuawABNJg+hw==",
"createdDateTime": "2022-02-02T09:29:25.2557072+00:00",
"lastModifiedDateTime": "2022-02-02T09:37:47.6734052+00:00",
"id": "AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQBGAAAAAACcxCFvSYx4Qq2TvvDk7ptoBwApGtasXg2jRLv-yfVbSS5rAAAAAAENAAApGtasXg2jRLv-yfVbSS5rAAE0tLDTAAA=",
"#odata.type": "microsoft.graph.event",
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('{userId}')/events/$entity",
"#odata.etag": "W/\"KRrWrF4No0S7/8n1W0kuawABNJg+hw==\"",
"occurrenceId": null,
"calendar#odata.associationLink": "https://graph.microsoft.com/v1.0/users('{userId}')/calendars('AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQAuAAAAAACcxCFvSYx4Qq2TvvDk7ptoAQApGtasXg2jRLv-yfVbSS5rAAAAAAENAAA=')/$ref",
"calendar#odata.navigationLink": "https://graph.microsoft.com/v1.0/users('userId')/calendars('AAMkAGJjMGZiYmVmLTdkNzctNDFjMy05MDdmLTQ5MzM1NWZjZWVhZQAuAAAAAACcxCFvSYx4Qq2TvvDk7ptoAQApGtasXg2jRLv-yfVbSS5rAAAAAAENAAA=')",
"responseHeaders": {
"cache-Control": ["private"],
"transfer-Encoding": ["chunked"],
"vary": ["Accept-Encoding"],
"strict-Transport-Security": ["max-age=31536000"],
"request-id": ["110a7a40-540d-46d2-9687-a50ea7994ab9"],
"client-request-id": ["110a7a40-540d-46d2-9687-a50ea7994ab9"],
"x-ms-ags-diagnostic": [
"{\"ServerInfo\":{\"DataCenter\":\"South India\",\"Slice\":\"E\",\"Ring\":\"2\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"MA1PEPF00002512\"}}"
],
"date": ["Wed, 02 Feb 2022 09:37:50 GMT"]
},
"statusCode": "OK"
}

Django Rest multilevel nested POST data in serializer

I have nested JSON data like below:
{
"resourceType": "Patient",
"identifier": [{
"use": "usual",
"type": {
"coding": [{
"code": "MR",
"display": "Medical Record Number"
}],
"text": "Medical Record Number"
},
"system": "http://example.com",
"value": "1032702",
"assigner": {
"reference": "Organization/198723168",
"display": "Reference Organization",
"data": {
"resourceType": "Organization",
"implicitRules": "",
"language": "",
"contained": "",
"extension": "",
"alias": "",
"contact": "",
"modifierExtension": "",
"active": true,
"name": "Clinic",
"address": [{
"line": [
"3300 Washtenaw Avenue, Suite 227"
],
"city": "Amherst",
"state": "MA",
"postalCode": "01002",
"country": "USA"
}]
}
}
}]
}
In serializers create method, I want to get the data which is nested to identifier->assigner and store that in organization serializer which different than this to which I am POSTing these data. For top level data I can do like validated_data.pop('identifier'). Is there a similar way for nested one?

Adaptive card fails to render when invoking an action command from the compose message area

I have a messaging extension bot in my Teams app, which is sending the following response when it receives a composeExtension/submitAction POST request:
{
"composeExtension": {
"attachments": [
{
"content": {
"type": "AdaptiveCard",
"body": [
{
"items": [
{
"color": null,
"horizontalAlignment": null,
"isSubtle": false,
"maxLines": 0,
"size": "large",
"text": "Solution: DoorDash",
"weight": "bolder",
"wrap": false,
"separator": false,
"type": "TextBlock"
},
{
"color": null,
"horizontalAlignment": null,
"isSubtle": true,
"maxLines": 0,
"size": "small",
"text": "No Needs • No Comments • No Upvotes",
"weight": null,
"wrap": true,
"separator": false,
"type": "TextBlock"
}
],
"separator": false,
"type": "Container"
},
{
"items": [
{
"horizontalAlignment": null,
"style": null,
"url": "https://urlp.asm.skype.com/v1/url/content?url=https%3a%2f%2fs3.us-east-1.amazonaws.com%2fstartgrid-v2-test-crunchbase-images%2forganizations%2fb%2f2%2fb2cximlauocyxfs2lkfh",
"width": "100px",
"height": "100px",
"separator": false,
"type": "Image"
},
{
"color": null,
"horizontalAlignment": null,
"isSubtle": false,
"maxLines": 0,
"size": null,
"text": "",
"weight": null,
"wrap": false,
"separator": false,
"type": "TextBlock"
},
{
"color": null,
"horizontalAlignment": null,
"isSubtle": false,
"maxLines": 0,
"size": null,
"text": "DoorDash enables delivery in areas where it was not previously available. The company's mission is to empower small business owners to offer delivery in an affordable and convenient way. We are achieving this mission first by enabling restaurant food delivery. DoorDash was founded in February 2013 by four Stanford students with experiences from Facebook, Square, Vevo, and eBay.",
"weight": null,
"wrap": false,
"separator": false,
"type": "TextBlock"
}
],
"separator": false,
"type": "Container"
}
],
"actions": [
{
"url": "xxxxxxxxxx",
"title": "View Solution",
"type": "Action.OpenUrl"
},
{
"url": "https://teams.microsoft.com/l/task/60864eb3-18fc-4710-9029-412157bce86b?height=600&url=xxxxxxxxxxx",
"title": "Add Comment",
"type": "Action.OpenUrl"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
},
"contentType": "application/vnd.microsoft.card.adaptive"
}
],
"type": "result",
"attachmentLayout": "list"
},
"responseType": "composeExtension"
}
The POST request has a 200 status code but the adaptive card fails to render and the following error message is displayed in the console: BotCardService: Error while resolving MRI from appAttribution. Error msg: {}
Please could you provide further information on what this error relates to?
Thanks.
Here are the steps you can follow:
We should add the commands in compose extension section in manifest file like below:
"composeExtensions": [
{
"botId": "xxxxxx-59e6-49b8-8b94-xxxxxxxxxx",
"commands": [
{
"id": "createAdaptiveCard",
"type": "action",
"context": [ "compose" ],
"description": "Command to run action to create a Card from Compose Box",
"title": "Adaptive Card",
"parameters": [
{
"name": "title",
"title": "Name",
"description": "Name of the User",
"inputType": "text"
},
{
"name": "subTitle",
"title": "Designation",
"description": "Designation of the User",
"inputType": "text"
},
{
"name": "text",
"title": "Description",
"description": "Description",
"inputType": "textarea"
}
]
},
{
"id": "webView",
"description": "Fetch the Web View",
"title": "Web View",
"type": "action",
"fetchTask": true,
"context": [ "compose" ]
},
{
"id": "HTML",
"description": "Fetch the HTML",
"title": "HTML",
"type": "action",
"fetchTask": true,
"context": [ "compose" ]
},
{
"id": "razorView",
"description": "Fetch the Razor View",
"title": "Razor View",
"type": "action",
"fetchTask": true,
"context": [ "compose" ]
}
]
}
],
You need to invoke the "createAdaptiveCard" action from the Messaging Extension action.
It will open a AdaptiveCard popup which is configured in your manifest.
Once you submit the card, it will handle the request at server side in below method:
protected override async Task OnTeamsMessagingExtensionSubmitActionAsync(ITurnContext turnContext, MessagingExtensionAction action, CancellationToken cancellationToken)
As a return response, you can return the Adaptive Card as attachment.
We have tried it at our end and it is working fine.
Please find below screenshot of it.
Please find below sample link for your reference:
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/51.teams-messaging-extensions-action

Including "siesta" in Schema.org OpeningHoursSpecification in JSON-LD

I'm using Schema.org OpeningHoursSpecification in JSON-LD in such a way:
[{"#type":"OpeningHoursSpecification","dayOfWeek": ["Monday","Tuesday","Wednesday","Thursday","Friday"],"open":"08:00","closes":"20:00"},{"#type":"OpeningHoursSpecification","dayOfWeek":["Saturday"],"open":"08:00","closes":"14:00"},{"#type":"OpeningHoursSpecification","dayOfWeek":["Sunday"],"open":"00:00","closes":"00:00"}]
I couldn't find any example for adapting this specification to include "siesta" - a situation when a place operates e.g. from 8AM to 1PM and from 3PM to 8PM.
EDITED PER #UNOR
This might get you started:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Service",
"url": "http://www.example.com/",
"hoursAvailable": [{
"#type": "OpeningHoursSpecification",
"opens": "08:00",
"closes": "13:00",
"dayOfWeek": [{
"#type": "DayOfWeek",
"#id": "http://schema.org/Monday",
"name": "Monday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Tuesday",
"name": "Tuesday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Wednesday",
"name": "Wednesday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Thursday",
"name": "Thursday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Friday",
"name": "Friday"
}]
},
{
"#type": "OpeningHoursSpecification",
"opens": "15:00",
"closes": "20:00",
"dayOfWeek": [{
"#type": "DayOfWeek",
"#id": "http://schema.org/Monday",
"name": "Monday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Tuesday",
"name": "Tuesday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Wednesday",
"name": "Wednesday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Thursday",
"name": "Thursday"
},
{
"#type": "DayOfWeek",
"#id": "http://schema.org/Friday",
"name": "Friday"
}]
}]
}
</script>
You can embellish with a more precise type of #Service and add time zone information.

Resources