Teams returning 502 error on invoke when consenting / declining file upload request

Shaun Lim 0 Reputation points
2023-03-08T07:52:42.0433333+00:00

Hi,

I have a bot that was built for Microsoft Teams and it depending on the scenario, the bot may send files across to the user. This bot is used purely for 1-to-1 (i.e. bot and user) interactions only.

A consent card is sent to the user by the bot and when the user clicks on accept or decline, it returns an error. Upon investigating using the developer tools using the browser, it seems to return a 502 error. The full error code is:

Request URL: https://au.ng.msg.teams.microsoft.com/v1/agents/28:xxx/invoke
Request Method: POST
Status Code: 502
Remote Address: xxx
Referrer Policy: strict-origin-when-cross-origin


{"errorCode":1008,"message":"<BotError>Error when processing invoke response: Unexpected character encountered while parsing value: A. Path '', line 0, position 0.","standardizedError":{"errorCode":1008,"errorSubCode":1,"errorDescription":"<BotError>Error when processing invoke response: Unexpected character encountered while parsing value: A. Path '', line 0, position 0."}}

From the message above, I am assuming that it might have something to do with the JSON payload that is sent but as far as I can tell, the payload is properly formatted. Below is an example of the payload that is sent back to my custom endpoint that does this processing:

{
  "name": "fileConsent/invoke",
  "messageType": "RichText/Media_Card",
  "value": {
    "action": "accept",
    "type": "fileUpload",
    "uploadInfo": {
      "contentUrl": "https://somedomain.com/some-file-name.pdf",
      "fileType": "pdf",
      "name": "some-file-name.pdf",
      "uniqueId": "c89d7ffb-8099-4638-b4c7-59e8606526d6",
      "uploadUrl":       "https://somedomain.sharepoint.com/personal/user_domain_com/_api/v2.0/drive/items/012JTFNO74P6O4RGMAHBDLJR2Z5BQGKJWW/uploadSession?guid='1eed3290-65bd-4533-87eb-e75fd058fe16'&overwrite=False&rename=True&dc=0&tempauth=xxxxxxxxxx",
      "UrlExpiry": 1678160927000
    }
  },
  "imdisplayname": "John Doe",
  "serverMessageId": "1678160628494",
  "clientMessageId": "1955409626770268261",
  "conversation": {
    "id": "19:460ac918-404a-4fc1-b418-dffc75fd8905_af9a22a7-4514-24f7-892b-e125e99c392d@unq.gbl.spaces"
  },
  "complianceData": {
    "action": { "type": "Action.Submit", "title": "Allow" }
  }
}

From my custom endpoint itself, it is receiving the payload and it is processing it correctly in an asynchronous manner and so the file does get uploaded successfully even though this error message appears.

[

](https://filestore.community.support.microsoft.com/api/images/886104d8-bc31-47b6-a9e5-eb132f20846a?upload=true)

Can anyone shed any light on why this error message appears? I am returning a 200 OK message back when my endpoint is sent the payload within 2 seconds.

Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,841 questions
{count} votes