OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

makeEwsRequestAsync returns error #4124

Closed yalcinborlu20 closed 6 months ago

yalcinborlu20 commented 7 months ago

Provide required information needed to triage your issue

I have an add-in for outlook web(outlook.live.com). Even though I have the correct xml and settings, makeEwsRequestAsync returns error (9020 GenericResponse). I'm trying to get detail of an email item (GetItem)

Your Environment

Expected behavior

Office.context.mailbox.makeEwsRequestAsync() should return the mail item instead of 9020 GenericResponseError.

Current behavior

Steps to reproduce

  1. Add custom addin(developed by me) for outlook web
  2. Click an email
  3. In the mail content, click menu button (three dot at right top)
  4. Click the custom addin option (like below) Screenshot 2024-02-12 at 13 44 45

Provide additional details

Here is the part of my custom addin js file (MessageRead.js)

const itemId = Office.context.mailbox.item.itemId;

const request = '<?xml version="1.0" encoding="utf-8"?>' +
    '<soap:Envelope xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"' +
    '               xmlns:xsd="https://www.w3.org/2001/XMLSchema"' +
    '               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
    '               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
    '  <soap:Header>' +
    '    <RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0" />' +
    '  </soap:Header>' +
    '  <soap:Body>' +
    '    <GetItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">' +
    '      <ItemShape>' +
    '        <t:BaseShape>IdOnly</t:BaseShape>' +
    '        <t:IncludeMimeContent>true</t:IncludeMimeContent>' +
    '        <t:AdditionalProperties>' +
    '            <t:FieldURI FieldURI="item:Subject" />' +
    '            <t:FieldURI FieldURI="item:ParentFolderId" />' +
    '            <t:FieldURI FieldURI="message:ToRecipients" />' +
    '            <t:FieldURI FieldURI="message:CcRecipients" />' +
    '            <t:FieldURI FieldURI="message:BccRecipients" />' +
    '            <t:FieldURI FieldURI="message:Sender" />' +
    '            <t:FieldURI FieldURI="item:DateTimeReceived" />' +
    '            <t:FieldURI FieldURI="item:InternetMessageHeaders" />' +
    '            <t:FieldURI FieldURI="item:Attachments" />' +
    '        </t:AdditionalProperties>' +
    '      </ItemShape>' +
    '      <ItemIds><t:ItemId Id="' + itemId + '"/></ItemIds>' +
    '    </GetItem>' +
    '  </soap:Body>' +
    '</soap:Envelope>';

        Office.context.mailbox.makeEwsRequestAsync(request, function (result) {
            const response = $.parseXML(result.value);
........
}

Here is the ss of debugging. itemId is correct. Screenshot 2024-02-12 at 10 33 32

Here is the manifest and html files for addin addin-manifest.txt OwaAddIn.txt

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

ajays-msft commented 7 months ago

@yalcinborlu20 -

Can you also please help with additional details like: 1) Is this working on other Outlook platforms like Desktop Outlook / Mac Outlook? 2) Are you able to get the ews api return the right value outside the office-js api (makeEwsRequest)? https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/get-started-with-ews-client-applications

yalcinborlu20 commented 7 months ago

Hey @ajays-msft Thank you for your quick response.

  1. It's not working for any platform
  2. I've already tried your suggestion. It returns 500 and giving me no detail. (The remote server returned an error: (500))
ajays-msft commented 7 months ago

@yalcinborlu20 - This forum is limited to issues related to office.js. Since this is related to EWS, for effective guidance, please get help from the ews forum as mentioned in the EWS documentation https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/start-using-web-services-in-exchange https://social.technet.microsoft.com/Forums/en-US/home?forum=exchangesvrdevelopment

yalcinborlu20 commented 7 months ago

Thank you @ajays-msft . I'm closing the ticket

yalcinborlu20 commented 7 months ago

@ajays-msft I tried one more time with EWSEditor. There is nothing wrong with EWS. It's working. I guess the problem is related to office.js. Here is my ss of request and response. It's the same xml request for web addin Screenshot 2024-02-13 at 12 34 24

msiint commented 7 months ago

I am running into the same issue for an Outlook add-in on both Mac and Outlook web.

I noticed in the console that it was making a request to https://outlook.live.com/owa/0/service.svc?action=GetClientAccessToken&app=Mail&n=80

with this as the response:

{
    "Header": {
        "ServerVersionInfo": {
            "MajorVersion": 15,
            "MinorVersion": 20,
            "MajorBuildNumber": 7270,
            "MinorBuildNumber": 33,
            "Version": "V2018_01_08"
        }
    },
    "Body": {
        "ResponseMessages": {
            "Items": [
                {
                    "__type": "GetClientAccessTokenResponseMessage:#Exchange",
                    "Token": null,
                    "MessageText": "An internal server error occurred. The operation failed., One or more errors occurred.",
                    "ResponseCode": "ErrorInternalServerError",
                    "ResponseClass": "Error"
                }
            ]
        }
    }
}

I am testing this on a personal Outlook account and the add-in has the ReadWriteMailbox permissions. This was also something that recently stopped working for the add-in.

ajays-msft commented 7 months ago

@msiint - Can you please create a separate issue for the problem you are seeing? In your case, getClientAccesToken is failing, and it is outlook.com account. In @yalcinborlu20 case, there is no report of getClientAccessToken failing, and it is a outlook365.com account.

yalcinborlu20 commented 7 months ago

@ajays-msft small chance but I guess it's worth to check. When I first tried to call directly to EWS in c# console app and got 500 error, there were no "ContentLength" and "UserAgent" headers. After I added these two headers to my request, I successfully got response from EWS.

msiint commented 7 months ago

@ajays-msft The add-in is also using the makeEwsRequestAsync API with the request

"<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <soap:Header>
        <t:RequestServerVersion Version="Exchange2013" />
      </soap:Header>
      <soap:Body>
        <GetItem
          xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <ItemShape>
            <t:BaseShape>IdOnly</t:BaseShape>
            <t:AdditionalProperties>
          <t:FieldURI FieldURI="item:Subject" />
          <t:FieldURI FieldURI="item:Body" />
          <t:FieldURI FieldURI="message:ToRecipients" />
          <t:FieldURI FieldURI="message:CcRecipients" />
          <t:FieldURI FieldURI="message:BccRecipients" />
          <t:FieldURI FieldURI="item:InternetMessageHeaders" />
        </t:AdditionalProperties>
          </ItemShape>
          <ItemIds>
            <t:ItemId Id=#{itemId} />
          </ItemIds>
        </GetItem>
      </soap:Body>
    </soap:Envelope>"

and failing with the same generic error response:

OSF.DDA.AsyncResult
{
    "status": "failed",
    "error": {
        "name": "GenericResponseError",
        "message": "An internal error has occurred.",
        "code": 9020
    }
}

I just noticed that during this request, the GetClientAccessToken is failing in the network console so I was thinking that this might be causing the makeEwsRequestAsync call to fail.

Any ideas why the GetClientAccessToken would be failing? Perhaps this is also failing for the OP. I see other service calls such as https://outlook.live.com/owa/0/service.svc?action=CreateItem being successful.

neprasad-microsoft commented 7 months ago

@msiint , can you paste the response for GetClientAccessToken?

yalcinborlu20 commented 7 months ago

@neprasad-microsoft I've also tried this. It returns 200 OK. Here is the response

{
    "Header": {
        "ServerVersionInfo": {
            "MajorVersion": 15,
            "MinorVersion": 20,
            "MajorBuildNumber": 7270,
            "MinorBuildNumber": 37,
            "Version": "V2018_01_08"
        }
    },
    "Body": {
        "ResponseMessages": {
            "Items": [
                {
                    "__type": "GetClientAccessTokenResponseMessage:#Exchange",
                    "Token": null,
                    "MessageText": "An internal server error occurred. The operation failed., One or more errors occurred.",
                    "ResponseCode": "ErrorInternalServerError",
                    "ResponseClass": "Error"
                }
            ]
        }
    }
}
yalcinborlu20 commented 7 months ago

Screenshot 2024-02-14 at 17 52 11

neprasad-microsoft commented 7 months ago

Hi @yalcinborlu20, is this also a custom add-in?

yalcinborlu20 commented 7 months ago

Hi @yalcinborlu20, is this also a custom add-in?

yes it is.

yalcinborlu20 commented 7 months ago

one more thing @neprasad-microsoft . It was working correctly last month. We have not changed anything. I hope this information helps.

msiint commented 7 months ago

@yalcinborlu20 I am experiencing the same symptoms to where the add-in was working up until recently but no changes have been deployed on our end.

@neprasad-microsoft Here's the response to GetClientAccessToken in my use case, it looks similar to what @yalcinborlu20 posted.

Request URL:
https://outlook.live.com/owa/0/service.svc?action=GetClientAccessToken&app=Mail&n=577
Request Method:
POST
Status Code:
200 OK

Response:
{
    "Header": {
        "ServerVersionInfo": {
            "MajorVersion": 15,
            "MinorVersion": 20,
            "MajorBuildNumber": 7270,
            "MinorBuildNumber": 33,
            "Version": "V2018_01_08"
        }
    },
    "Body": {
        "ResponseMessages": {
            "Items": [
                {
                    "__type": "GetClientAccessTokenResponseMessage:#Exchange",
                    "Token": null,
                    "MessageText": "An internal server error occurred. The operation failed., One or more errors occurred.",
                    "ResponseCode": "ErrorInternalServerError",
                    "ResponseClass": "Error"
                }
            ]
        }
    }
}

Although sometimes, I notice this will be the response body:

{
    "Header": {
        "ServerVersionInfo": {
            "MajorVersion": 15,
            "MinorVersion": 20,
            "MajorBuildNumber": 7270,
            "MinorBuildNumber": 33,
            "Version": "V2018_01_08"
        }
    },
    "Body": {
        "ResponseMessages": {
            "Items": [
                {
                    "__type": "GetClientAccessTokenResponseMessage:#Exchange",
                    "Token": {
                        "Id": *REDACTED*,
                        "TokenType": "CallerIdentity",
                        "TokenValue": *REDACTED*,
                        "TTL": 60
                    },
                    "ResponseCode": "NoError",
                    "ResponseClass": "Success"
                },
                {
                    "__type": "GetClientAccessTokenResponseMessage:#Exchange",
                    "Token": null,
                    "MessageText": "An internal server error occurred. The operation failed., One or more errors occurred.",
                    "ResponseCode": "ErrorInternalServerError",
                    "ResponseClass": "Error"
                }
            ]
        }
    }

Both of these responses causes the makeEwsRequestAsync call to fail with the generic 9020 error.

neprasad-microsoft commented 7 months ago

Thanks for reporting this issue regarding GetClientAccessToken. It has been put on our backlog and we are working on a fix. We unfortunately have no timelines to share at this point.   Internal tracking id: Office: [4335835]

msiint commented 7 months ago

@neprasad-microsoft

Thank you. Is there a non-internal place where we can track the progress of this ticket? Any idea about the root cause?

neprasad-microsoft commented 7 months ago

Hi @msiint Unfortunately, there is no other place where you can track this issue. This GitHub issue will remain open till it is fixed. We are working on a fix and will share an update here once the fix is available.

ajays-msft commented 7 months ago

@yalcinborlu20 and @msiint - By any chance the account you are using, is it a vanity domain?

yalcinborlu20 commented 7 months ago

Hi @ajays-msft I'm using outlook.com domain. If it's necessary I can also give you the email.

benjidotsh commented 7 months ago

Just chiming in: we're encountering the same issue with an outlook.com email address. It has been working fine in production for almost a year now, but now it's suddenly not working anymore.

msiint commented 7 months ago

@ajays-msft Also using an outlook.com domain personal email address.

ajays-msft commented 7 months ago

We are investigating this issue, and will provide an update when available.

ajays-msft commented 6 months ago

This issue is now resolved.