Error when attempting to create VSTS API Service Hook Subscription - visual-studio

Everyone,
I have been around and around about creating Visual Studio Team Services - Service Hook Subscriptions automagically via API. I can get the TFS publisher to work, but not the RM publisher. I am trying to create a hook subscription for Release Deployment Completed. Any examples I can find simply don't work even when swapped with my data. TFS provider works perfecty. Sample with response...
POST https://project.visualstudio.com/_apis/hooks/subscriptions?api-version=4.1-preview
Body:
{
"publisherId": "rm",
"eventType": "ms.vss-release.deployment-completed-event",
"consumerId": "slack",
"consumerActionId": "postMessageToChannel",
"publisherInputs": {
"releaseEnvironmentId" : "777",
"releaseDefinitionId" : "1",
"releaseEnvironmentStatus" : "4",
"projectId" : "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"
},
"consumerInputs": {
"url": "https://hooks.slack.com/services/myservice/crazyGuidxxxxxxxxxxxxxxxx"
}
}
Response:
{
"$id": "1",
"innerException": null,
"message": "There is no registered handler for the service hooks event type ms.vss-release.deployment-completed-event.",
"typeName": "System.InvalidOperationException, mscorlib",
"typeKey": "InvalidOperationException",
"errorCode": 0,
"eventId": 0
}

It's because you missed vsrm in your url for a release. Use the following api and you'll get a successful response:
POST https://project.vsrm.visualstudio.com/_apis/hooks/subscriptions?api-version=4.1-preview

Related

Teams is not displaying my unfurl response

I have a Teams integration with link unfurling set up. I have the messaging endpoint pointed to a public ngrok URL and ngrok proxying a local node.js server that returns the example payload Microsoft has in it's documentation.
This is my endpoint (express.js):
app.post('/bot-test', (req, res) => {
res.send({
"composeExtension": {
"type": "result",
"attachmentLayout": "list",
"attachments": [
{
"contentType": "application/vnd.microsoft.teams.card.o365connector",
"content": {
"sections": [
{
"activityTitle": "[85069]: Create a cool app",
"activityImage": "https://placekitten.com/200/200"
},
{
"title": "Details",
"facts": [
{
"name": "Assigned to:",
"value": "[Larry Brown](mailto:larryb#example.com)"
},
{
"name": "State:",
"value": "Active"
}
]
}
]
}
}
]
}
});
});
When I post a URL in a message in Teams, I see it POST to that endpoint and it responds without errors, but nothing shows up in Teams. What's going wrong? I can't find any logs on Microsoft's side either. I would expect that Teams renders a card with the response payload.
Office 365 Connector cards are not supported for link unfurls ("Message extension previews" in MS parlance). Changing the response to a supported card type worked. Unfortunately, MS doesn't surface this problem anywhere and it just silently discards the response. I was able to find a somewhat useful error description by inspecting the network request that went out from the Teams web client, however.
See this for supported card types: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference

How do you subscribe to push notifications in microsoft graph?

I have been trying to figure out how to use the beta notifications resource to send push notifications to users in Teams, but I cannot get past step 1.
User signs in to your application, which creates a subscription with the Microsoft Graph notification service.
I am not using a language with Microsoft library support so I cannot use their SDKs. Instead, I am manually sending http requests. I have tried many, but I can't even nail down what the "resource" is supposed to be in the subscription type. Here are some of the things I have tried and the results:
Sending this message:
{
"changeType": "created",
"notificationUrl": "https://(...)/notifications",
"resource": "me/notifications",
"expirationDateTime": "2020-11-04T18:23:45.9356913Z"
}
Results in:
{
"error": {
"code": "InvalidRequest",
"message": "Subscription for resource 'me/notifications' is not supported.",
"innerError": {
"date": "2020-11-04T17:12:24",
"request-id": "66172d3c-298d-47d4-babb-52d96ef42179",
"client-request-id": "1c20849c-fcda-0b07-56e3-5bed08bb28e4"
}
}
}
The above message also correctly calls my server's /notifications route with this param:
Validation: Testing client application reachability for subscription Request-Id: 2f3cc3b8-b2c2-5922-451c-433add43bc74
Sending this one:
{
"changeType": "created",
"notificationUrl": "https://(...)/notifications",
"resource": "notification",
"expirationDateTime": "2020-11-04T18:23:45.9356913Z"
}
Results in:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'notification'.",
"innerError": {
"date": "2020-11-04T17:21:15",
"request-id": "d894c93b-9dac-4051-a3af-cb6039f1394b",
"client-request-id": "84d18ec7-2c67-8240-b576-03641b3b5a59"
}
}
}
I have also tried "notifications", "users/me/notifications", and a few others to no avail. What's the deal, Microsoft? This resource isn't even listed under the possible subscription types in the beta docs, so is it supported or not?
At this point I'm pretty sure this functionality just doesn't work/exist.

OfficeJs getUserIdentityTokenAsync failed to generate the token

One of our customers faced an issue while using our Add-in for Microsoft Office.
When we call getUserIdentityTokenAsync it fails with an error
{"value":null,"status":"failed","error":{"name":"InternalServerError","message":"The Exchange server returned an error. Please look at the diagnostics object for more information.","code":9042},"diagnostics":{"ErrorText":"The token for this extension could not be retrieved."}}
It happened on Microsoft Exchange 2016 on perm.
In dev console, I found the following API call
/owa/service.svc?action=GetClientAccessToken&EP=1&ID=-23&AC=1
with the following request header
"name": "X-OWA-ActionName",
"value": "Ext_GetUserIdentityToken"
and these headers in the response
{
"name": "X-OWA-Version",
"value": "15.1.1847.7"
},
{
"name": "X-OWA-OWSVersion",
"value": "V2017_08_18"
},
{
"name": "X-OWA-DiagnosticsInfo",
"value": "29;12;3"
},
{
"name": "X-OWA-Error",
"value": "Microsoft.Exchange.Services.Core.Types.ErrorInvalidClientAccessTokenRequestException"
},
I believe it is customer's Exchange misconfiguration but could someone help me to understand what exactly not configured on Exhcange side?
Could it be a proxy configuration or something?
There is an X-OWA-CorrelationId response header, where I can find any information with that code?
many thanks.

Twilio API not receiving current location via WhatsApp channel

I am currently building a bot using Twilio's WhatsApp integration with Twilio Studio. I need users to be able to share their current location with the bot, but found that if I send a location through WhatsApp, the body of the message that is sent to Twilio Studio is blank. I have tested other scenarios, such as sending a textual message, images, etc. and it all works fine, except when sharing location messages.
Does anyone know if WhatsApp location messages are currently not supported by Twilio?
Below is an example of the trigger message that is received by Twilio Studio whenever I send my current location through WhatsApp.
Thanks!
{
"contact": {
"channel": {
"address": "whatsapp:+34..."
}
},
"trigger": {
"message": {
"ApiVersion": "2010-04-01",
"SmsSid": "SM32631478ffaaf810cf5976df7586708f",
"SmsStatus": "received",
"SmsMessageSid": "SM32631478ffaaf810cf5976df7586708f",
"NumSegments": "1",
"From": "whatsapp:+34...",
"To": "whatsapp:+1...",
"MessageSid": "SM32631478ffaaf810cf5976df7586708f",
"Body": "",
"AccountSid": "ACc66461614830932cb12fdc6ab9d1d0a7",
"NumMedia": "0"
}
},
"widgets": {},
"flow": {
"flow_sid": "FWf8aae0f75a993b4a497aa6a569a54114",
"channel": {
"address": "whatsapp:+1..."
},
"sid": "FN522a44cadf024dc69d055c6690244db0"
}
}
If a location is present in your whatsApp text you can fetch it the same way you fetch your body
if (req.body.Latitude && req.body.Longitude) {
console.log('Whatsapp location received...');
console.log(req.body.Latitude + ', ' + req.body.Longitude);
}
I have just received an answer from Twilio that clarifies this is not something that Twilio supports at this stage. They do not currently have any ETA for when this feature will be available.

Google Logging API - What service name to use when writing entries from non-Google application?

I am trying to use Google Cloud Logging API to write log entries from a web application I'm developing (happens to be .net).
To do this, I must use the logging.projects.logs.entries.write request. This request dictates that I provide a serviceName argument:
{
"entries": [
{
"textPayload": "test",
"metadata":
{
"serviceName": "compute.googleapis.com"
"projectId": "...",
"region": "us-central1",
"zone": "us-central1-a",
"severity": "DEFAULT",
"timestamp": "2015-01-13T19:17:01Z",
"userId": "",
}
}]
}
Unless I specify "compute.googleapis.com" as the serviceName I get an error 400 response:
{
"error":
{
"code": 400,
"message": "Unsupported service specified",
"status": "INVALID_ARGUMENT"
}
}
For now using "compute.googleapis.com" seems to work but I'm asking - what service name should I give, given that I'm not using Google Compute Engine or Google App Engine here?
The Cloud Logging API currently only officially supports Google resources, so the best course of action is to continue to use "compute.googleapis.com" as the service and supply the labels "compute.googleapis.com/resource_type" and "compute.googleapis.com/resource_id", which are used for indexing and visible in the UI drop-downs.
We also currently permit the service name "custom.googleapis.com" with index labels "custom.googleapis.com/primary_key" and "custom.googleapis.com/secondary_key" but that is not officially supported and subject to change in a future release.

Resources