I have a Bot App running in Microsoft Teams. There I have made this bot able to receive files. Everything works fine if I upload a photo as attachment. Request looks like this:
{
"attachments": [
{
"contentType": "image/*",
"contentUrl": ";
},
{
"contentType": "text/html",
"content": "<p><img alt=\"Media\" itemscope=\"\" itemtype=\"\" src=\"\" width=\"2160\" height=\"2880\"></p>"
}
],
"type": "message",
"timestamp": "2025-03-13T10:32:32.4231917Z",
"localTimestamp": "2025-03-13T11:32:32.4231917+01:00",
"id": "1741861952394",
"channelId": "msteams",
"serviceUrl": "/",
"from": {
"id": "29:1lS78FUfVVN2WkvaLn8Fls8zpmivS9RxWo974AOv2tRCx31YGchqABn5FeHxzSCm-3n6HdgjDOVCiuxl-Za80qg",
"name": "Test User",
"aadObjectId": "33b192a6-0216-47-14599fe0f26a"
},
"conversation": {
"conversationType": "personal",
"tenantId": "0f6e1639-5b36-450e-95e3-1f",
"id": "a:1QeVDpdUTPxM_fRgWx3QMckI6mGhTRST6_lBlM1qGRSfiJOJVPCpJ0XKaS3frJEZOcGeo7nyEDWsb0b_hXUXeURwhSGLIqEZfQxlYg1k7pMtZ"
},
"recipient": {
"id": "28:a2670ec4-57d7-4012-9e45-858e",
"name": "TestBot"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Android",
"timezone": "Europe/Berlin",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "0f6e1639-5b36-450e-95e3-ee40b1f"
}
},
"locale": "en-US",
"localTimezone": "Europe/Berlin"
}
Then I can normally access the photo and process it further.
However if I do it with camera directly then request looks like this:
{
"type": "message",
"timestamp": "2025-03-13T10:30:33.8343393Z",
"localTimestamp": "2025-03-13T11:30:33.8343393+01:00",
"id": "174133798",
"channelId": "msteams",
"serviceUrl": "/",
"from": {
"id": "29:1lS78FUfVVN2WkvaLn8F5FeHxzSCm-3n6Hdgxl-Za80qg",
"name": "Test User",
"aadObjectId": "33b192a6-0216-4a96-a467-145926a"
},
"conversation": {
"conversationType": "personal",
"tenantId": "0f6e1639-5b36-450e-95e3-ef5439e40b1f",
"id": "a:1QeVDpdUTPxM_fRgWx3QMckIVkunJLFyCAOcC_lBlM1qGRSfiJOJVOcGeo7nyEDWsb0b_hXUxlYg1k7pMtZ"
},
"recipient": {
"id": "28:a2ec4-57d7-4012-9e45-8b48e",
"name": "Test Bot"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Android",
"timezone": "Europe/Berlin",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "0f6e1639-5b36-450e-95e3-ef5"
}
},
"locale": "en-US",
"localTimezone": "Europe/Berlin"
}
And I am getting :
{"error":{"code":"BotError","message":"Access Forbidden"}}
and 403.
Was anyone having something similar? I have noticed that while using attachment upload it forwards the files to my sharepoint url which is not the case with directly uploaded photos.
I am trying to get the image like this:
using (HttpClient httpClient = new HttpClient())
{
var token = await new MicrosoftAppCredentials("MYAPPID", "MYAPPSECRET").GetTokenAsync();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var responseMessage = await httpClient.GetAsync(url); // here url is like /...
var contentLenghtBytes = responseMessage.Content.Headers.ContentLength;
if (responseMessage.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("Done with status '" + responseMessage.StatusCode + "'");
}
}
It should be simple where I have url of the image and using the token I should be able to get it. But like I said the url is different when the photo is taken directly from the camera. (comparing to one with attachment where we have sharepoint url).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744707194a4589123.html
评论列表(0条)