OfficeDev / Office-Add-in-samples

Code samples for Office Add-in development on the Microsoft 365 platform.
MIT License
744 stars 804 forks source link

Error: BadRequest: Id is missing from xml package. #852

Closed strtob closed 1 month ago

strtob commented 1 month ago

Note: This repo is only for questions related to its samples. If you have questions about how to use office.js or the Office developer platform, please post your question on https://stackoverflow.com. Tag your question with office-js or outlook-web-addins

Question

I'm new to office_add-in and try to get a bestter understanding based on you samples like this https://github.com/OfficeDev/Office-Add-in-samples/tree/main/Samples/outlook-check-item-categories

My manifest.xml look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
    <Id>
        1bf1ebb0-46fc-4fbb-ad40-49dc0928f4ce
    </Id>
    <Version>
        1.0.0.0
    </Version>
    <ProviderName>
        Contoso
    </ProviderName>
    <DefaultLocale>
        en-US
    </DefaultLocale>
    <DisplayName DefaultValue="sample-outlook-add-in" />
    <Description DefaultValue="A template to get started." />
    <IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png" />
    <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png" />
    <SupportUrl DefaultValue="https://www.contoso.com/help" />
    <AppDomains>
        <AppDomain>
            https://www.contoso.com
        </AppDomain>
    </AppDomains>
    <Hosts>
        <Host Name="Mailbox" />
    </Hosts>
    <Requirements>
        <Sets>
            <Set Name="Mailbox" MinVersion="1.1" />
        </Sets>
    </Requirements>
    <FormSettings>
        <Form xsi:type="ItemRead">
            <DesktopSettings>
                <SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
                <RequestedHeight>
                    250
                </RequestedHeight>
            </DesktopSettings>
        </Form>
    </FormSettings>
    <Permissions>
        ReadWriteItem
    </Permissions>
    <Rule xsi:type="RuleCollection" Mode="Or">
        <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
    </Rule>
    <DisableEntityHighlighting>
        false
    </DisableEntityHighlighting>
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.10">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">
        <!-- Event-based activation happens in a lightweight runtime.-->
        <Runtimes>
          <!-- HTML file including reference to or inline JavaScript event handlers.
               This is used by Outlook on the web and on the new Mac UI, and new Outlook on Windows. -->
          <Runtime resid="WebViewRuntime.Url">
            <!-- JavaScript file containing event handlers. This is used by classic Outlook on Windows. -->
            <Override type="javascript" resid="JSRuntime.Url"/>
          </Runtime>
        </Runtimes>
        <DesktopFormFactor>
          <FunctionFile resid="Launchevent.Url" />
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="msgReadGroup">
                <Label resid="GroupLabel" />
                <Control xsi:type="Button" id="msgReadOpenPaneButton">
                  <Label resid="TaskpaneButton.Label" />
                  <Supertip>
                    <Title resid="TaskpaneButton.Label" />
                    <Description resid="TaskpaneButton.Tooltip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16" />
                    <bt:Image size="32" resid="Icon.32x32" />
                    <bt:Image size="80" resid="Icon.80x80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="Taskpane.Url" />
                  </Action>
                </Control>
                <Control xsi:type="Button" id="ActionButton">
                  <Label resid="ActionButton.Label"/>
                  <Supertip>
                    <Title resid="ActionButton.Label"/>
                    <Description resid="ActionButton.Tooltip"/>
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16x16"/>
                    <bt:Image size="32" resid="Icon.32x32"/>
                    <bt:Image size="80" resid="Icon.80x80"/>
                  </Icon>
                  <Action xsi:type="ExecuteFunction">
                    <FunctionName>action</FunctionName>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>

          <!-- Can configure other command surface extension points for add-in command support. -->

          <!-- Enable launching the add-in on the included events. -->
          <ExtensionPoint xsi:type="LaunchEvent">
            <LaunchEvents>
              <LaunchEvent Type="OnNewMessageCompose" FunctionName="onNewMessageComposeHandler"/>
              <LaunchEvent Type="OnNewAppointmentOrganizer" FunctionName="onNewAppointmentComposeHandler"/>
            </LaunchEvents>
            <!-- Identifies the runtime to be used (also referenced by the Runtime element). -->
            <SourceLocation resid="WebViewRuntime.Url"/>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
        <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
        <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Launchevent.Url" DefaultValue="https://localhost:3000/launchevent.html" />
        <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
        <bt:Url id="WebViewRuntime.Url" DefaultValue="https://localhost:3000/launchevent.html" />
        <!-- Entry needed for classic Outlook on Windows. -->
        <bt:Url id="JSRuntime.Url" DefaultValue="https://localhost:3000/runtime.js" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
        <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
        <bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
        <bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</VersionOverrides>
</OfficeApp>`

I get this error:

--Error sideloading!--
Error: Error: Command failed: npx @microsoft/teamsapp-cli install --xml-path "C:\Users\Tobia\work\costlight-outlook-add-in\manifest.xml"
(×) Error: M365.PackageServiceError: Request failed with status code 400 (tracingId: 00-4ad2ca2458fd44ef580538a08a3338d7-72b0febf4f37f7eb-00) BadRequest: Id is missing from xml 
package.

STDERR:
(×) Error: M365.PackageServiceError: Request failed with status code 400 (tracingId: 00-4ad2ca2458fd44ef580538a08a3338d7-72b0febf4f37f7eb-00) BadRequest: Id is missing from xml 
package.

Error: Unable to start debugging.
Error: Unable to sideload the Office Add-in.
Error: Command failed: npx @microsoft/teamsapp-cli install --xml-path "C:\Users\Tobia\work\costlight-outlook-add-in\manifest.xml"
(×) Error: M365.PackageServiceError: Request failed with status code 400 (tracingId: 00-4ad2ca2458fd44ef580538a08a3338d7-72b0febf4f37f7eb-00) BadRequest: Id is missing from xml 
package.

In the manifest.xml an ID is defined. Whats wrong?

Thank for your efforts to help! Tobi

AlexJerabek commented 1 month ago

Hi @strtob,

Thanks for reaching out. Based on the pasted XML, I think it's the additional whitespace in some of your fields (like ID). White space between tags is passed to the application and I don't think we're trimming the GUID on our end. So, instead of having XML like

<Id>
    1bf1ebb0-46fc-4fbb-ad40-49dc0928f4ce
</Id>

Try this:

<Id>1bf1ebb0-46fc-4fbb-ad40-49dc0928f4ce</Id>

The original sample's manifest should be formatted like that in the repo.

Let me know if that doesn't fix the problem.

strtob commented 1 month ago

Hi @AlexJerabek, what a stupid mistake, thanks a lot! :-)

In Outlook 2021, unfortunately this button don't want to appear, have you any idea? :-(

<ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="CategoriesGroupAppointmentOrganizer">
                  <Label resid="CategoriesGroupLabel"/>
                  <Control xsi:type="Button" id="AppointmentOrganizerSelectButton">
                    <Label resid="SelectButtonLabel"/>
                    <Supertip>
                      <Title resid="SelectButtonLabel"/>
                      <Description resid="SelectButtonDescription"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16" />
                      <bt:Image size="32" resid="Icon.32x32" />
                      <bt:Image size="80" resid="Icon.80x80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url"/>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>

I've started with npm run build and then npm start. There are no erros and outlook opens, according to settings the add-in is installed but no button appears if you open a new appointment?

strtob commented 1 month ago

I've got it, just need to remove the requirement tag:

  <Requirements>
        <bt:Sets DefaultMinVersion="1.12">
          <bt:Set Name="Mailbox"/>
        </bt:Sets>
</Requirements>