Unable to add teams app in app catalog using Microsoft graph API

Nitin S 31 Reputation points
2021-07-26T17:23:39.103+00:00

I want to upload my teams app package to catalog but i am not able to do it. I am following https://learn.microsoft.com/en-us/graph/api/teamsapp-publish?view=graph-rest-1.0&tabs=http

Please help

curl -F "data=@/home/Downloads/app_package.zip" -H "Authorization: Bearer user_token" -H "Content-length: 244" -H "Content-type: application/zip" -X POST https://graph.microsoft.com/v1.0/appCatalogs/teamsApps

Getting-

{"error":{"code":"BadRequest","message":"Invalid zip archive provided, ex: End of Central Directory record could not be found.","innerError":{"date":"2021-07-26T19:49:55","request-id":"f501141a-c74d-4df2-842a-e5f784732558","client-request-id":"f501141a-c74d-4df2-842a-e5f784732558"}}}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,008 questions
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.
3,250 questions
Microsoft 365 Publishing
Microsoft 365 Publishing
Microsoft 365: Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line. Publishing: The process of preparing, producing, and releasing content for distribution or sale.
618 questions
{count} votes

Accepted answer
  1. Prasad-MSFT 6,766 Reputation points Microsoft Vendor
    2021-08-04T09:20:39.59+00:00

    There are various reasons for this type error:

    1. The archive is corrupt.
      Solution - The archive will need repairing.
    2. It is not a .zip archive.
      It may be a .rar or other compressed type.
      Solution - Have to find a correct archive to use this code.
    3. There is more than 1 part to the archive.
      A multi part zip file.
      Solution - Read in all the files before decompression.
    4. The file may be hidden or have extended characters in the name.
      Solution - Check your file attributes/permissions and verify the file name.

    Opening the file with your favorite zip/unzip utility (7-zip, winzip, etc) will tell which of these it could be.

    Thanks,
    Prasad Das


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.


1 additional answer

Sort by: Most helpful
  1. Selmison Miranda 0 Reputation points
    2023-10-05T19:20:08.24+00:00

    The reason is that the option --data in curl pass the data using the content-type application/x-www-form-urlen‐coded.

    The endpoint is prepared for receiving the data in binary format.

    To fix this use --data-binary option, like that:

    curl --data-binary @appPackage.zip -H "Authorization: Bearer ${TOKEN}" -H "Content-length: 35776" -H "Content-type: application/zip" -X POST https://graph.microsoft.com/v1.0/appCatalogs/teamsApps

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.