使用适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API,以编程方式为你的或你所属组织的合作伙伴中心帐户查询和创建 MSI 或 EXE 应用的提交。 当你的帐户管理着多个应用或加载项,而你想要自动执行并优化这些资源的提交过程时,此 API 十分实用。 此 API 使用 Microsoft Entra ID 对来自应用或服务的调用进行身份验证。
以下步骤介绍了使用 Microsoft Store 提交 API 的端到端过程:
- 确保已完成所有先决条件。
- 在 Microsoft 应用商店提交 API 中调用方法之前,请获取Microsoft Entra ID 访问令牌。 获取令牌后,可以在 60 分钟的令牌有效期内,使用该令牌调用“Microsoft Store 提交 API”。 该令牌到期后,可以重新生成一个。
- 调用适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API。
步骤 1:完成使用 Microsoft Store 提交 API 的先决条件
在开始编写调用 适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 的代码之前,请确保已完成以下先决条件。
- (或组织)必须具有Microsoft Entra ID 目录,并且必须具有目录的全局管理员权限。 如果已在 Microsoft 中使用 Microsoft 365 或其他业务服务,则已有Microsoft Entra ID 目录。 否则,可以在 合作伙伴中心创建新的 Microsoft Entra ID ,无需额外付费。
- 必须将 Microsoft Entra ID 应用程序与合作伙伴中心帐户相关联,并获取租户 ID、客户端 ID 和密钥。 需要这些值才能获取Microsoft Entra ID 访问令牌,该令牌将在调用 Microsoft 应用商店提交 API 时使用。
- 为你的应用做好使用 Microsoft Store 提交 API 的准备:
- 如果合作伙伴中心中尚不存在你的应用,需要通过在合作伙伴中心保留其名称来创建你的应用。 不能使用 Microsoft Store 提交 API 在合作伙伴中心创建应用;需要在合作伙伴中心进行创建,然后才能使用 API 访问应用,并以编程方式为其创建提交。
- 在使用此 API 为给定应用创建提交之前,必须先在合作伙伴中心 为应用创建一个提交 ,包括回答 年龄分级 问卷。 执行此操作后,就能够使用 API 以编程方式为此应用创建新提交。
- 如果要创建或更新应用提交,并且需要包括新包, 请准备程序包详细信息。
- 如果要创建或更新应用提交,并且需要包括应用商店一览的屏幕截图或 图像,请准备应用屏幕截图和图像。
如何将 Microsoft Entra ID 应用程序与合作伙伴中心帐户相关联
必须先将 Microsoft Entra ID 应用程序与合作伙伴中心帐户相关联,然后才能使用适用于 MSI 或 EXE 应用的 Microsoft 应用商店提交 API,检索应用程序的租户 ID 和客户端 ID 并生成密钥。 Microsoft Entra ID 应用程序表示要从中调用Microsoft应用商店提交 API 的应用或服务。 需要租户 ID、客户端 ID 和密钥才能获取传递给 API 的 Microsoft Entra ID 访问令牌。
注意
你只需执行一次此任务。 拥有租户 ID、客户端 ID 和密钥后,可以随时重复使用它们,以创建新的Microsoft Entra ID 访问令牌。
- 在合作伙伴中心, 将组织的合作伙伴中心帐户与组织的Microsoft Entra ID 目录相关联。
- 接下来,在合作伙伴中心“帐户设置”部分的“用户”页中,添加 Microsoft Entra ID 应用程序,该应用程序对应于你将用于访问你的合作伙伴中心帐户中的提交内容的应用或服务。 确保为此应用程序分配“管理者”角色。 如果Microsoft Entra ID 目录中尚不存在该应用程序,则可以 在合作伙伴中心创建新的Microsoft Entra ID 应用程序。
- 返回到“用户”页,单击Microsoft Entra ID 应用程序的名称以转到应用程序设置,并复制租户 ID 和客户端 ID 值。
- 若要添加新密钥或客户端密码,请参阅以下说明,或参考通过 Azure 门户注册应用的说明:
要注册应用,请执行以下操作:
登录到 Azure 门户。
如果有权访问多个租户,请使用顶部菜单中的“目录 + 订阅”筛选器 ,以切换到要在其中注册应用程序的租户。
搜索并选择Microsoft Entra ID Directory。
在“管理”下,选择“应用注册”>,然后选择你的应用程序 。
选择“证书和机密”>“客户端密码”>“新建客户端密码”。
为客户端机密添加描述。
选择机密的过期时间,或指定自定义的生存期。
客户端机密生存期限制为两年(24 个月)或更短。 不能指定超过 24 个月的自定义生存期。
注意
Microsoft 建议将过期时间值设置为小于 12 个月。
选择 添加 。
记录机密的值,以便在客户端应用程序代码中使用。 退出此页面后,此机密值永不再显示。
步骤 2:获取Microsoft Entra ID 访问令牌
在调用适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 中的任何方法之前,必须先获取 Microsoft Entra ID 访问令牌,并将其传递到该 API 中每个方法的 Authorization 标头中。 获取访问令牌后,你有 60 分钟的时间来使用它,60 分钟后它将过期。 该令牌到期后,可以对它进行刷新,以便可以在之后调用该 API 时继续使用。
若要获取访问令牌,请按照 服务到服务调用中的说明使用客户端凭据 将 HTTP POST 发送到 https://login.microsoftonline.com/<tenant_id>/oauth2/token 终结点。 示例请求如下所示。
POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8
grant_type=client_credentials
&client_id=<your_client_id>
&client_secret=<your_client_secret>
&scope=https://api.store.microsoft.com/.default
请为 POST URI 中的 tenant_id 值,以及 client_id 和 client_secret 参数指定在上一节中从合作伙伴中心获取的应用程序租户 ID、客户端 ID 和密钥。 对于 scope 参数,必须指定 https://api.store.microsoft.com/.default。
在你的访问令牌到期后,你可按照此处的说明刷新令牌。
有关演示如何使用 C# 或 Node.js获取访问令牌的示例,请参阅适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 的代码示例 。
第 3 步:使用Microsoft Store 提交 API
获取 Microsoft Entra ID 访问令牌后,您就可以调用适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 中的方法。 该 API 的许多方法已经按应用的场景分类。 要创建或更新提交,一般需按特定顺序调用多个方法。 有关各场景中每个方法的语法信息,请参见以下节:
注意
获取访问令牌后,在令牌过期前的 60 分钟内,你可以调用用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 中的方法。
基础 URL
适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API的基 URL 为:https://api.store.microsoft.com
API 协定
获取当前草稿提交元数据 API
提取当前草稿提交下每个模块(列表、属性或可用性)的元数据。
路径 [所有模块]: /submission/v1/product/{productId}/metadata?languages={languages}&includelanguagelist={true/false}
路径 [单一模块]: /submission/v1/product/{productId}/metadata/{moduleName}?languages={languages}&includelanguagelist={true/false}
方法:GET
路径参数
| 参数 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
| 模块名 | 合作伙伴中心模块 - 列表、属性或可用性 |
查询参数
| 参数 | 说明 |
|---|---|
| 语言 |
可选 语言列表筛选器支持以逗号分隔的字符串格式 [最多可包含 200 种语言]。 如果空置,将提取前 200 个可用的列表语言元数据。 [例如“en-us, en-gb"]。 |
| includelanguagelist | 自选 布尔值 – 如果为 true,则返回添加的列表语言及其完整性状态的列表。 |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
在 Partner Center 帐户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| accessibilitySupport | 布尔 | |
| 附加许可条款 | 字符串 | |
| 可用性 | 物体 | 可用性模块数据 |
| 分类 | 字符串 | 请参阅下面的类别列表 |
| certificationNotes | 字符串 | |
| 代码 | 字符串 | 消息的错误代码 |
| 联系信息 | 字符串 | |
| 版权 | 字符串 | |
| dependsOnDriversOrNT | 布尔 | |
| description | 字符串 | |
| developedBy | 字符串 | |
| 可发现性 | 字符串 | [DISCOVERABLE, DEEPLINK_ONLY] |
| enableInFutureMarkets | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| FreeTrial | 字符串 | [NO_FREE_TRIAL, FREE_TRIAL] |
| hardwareItemType | 字符串 | |
| isPrivacyPolicyRequired | 布尔 | |
| isRecommended | 布尔 | |
| 是否必填 | 布尔 | |
| isSuccess | 布尔 | |
| isSystemFeatureRequired | 对象数组 | |
| 语言 | 字符串 | 查看语言列表 |
| 清单 | 对象数组 | 列出每种语言的模块数据 |
| markets | 字符串数组 | 请参阅下面的市场列表 |
| 消息 | 字符串 | 对错误的说明 |
| minimumHardware | 字符串 | |
| minimumRequirement | 字符串 | |
| penAndInkSupport | 布尔 | |
| 定价 | 字符串 | [FREE, FREEMIUM, SUBSCRIPTION, PAID] |
| 隐私政策网址 | 字符串 | |
| 产品声明 | 物体 | |
| productFeatures | 字符串数组 | |
| properties | 物体 | 属性模块数据 |
| 推荐硬件 | 字符串 | |
| recommendedRequirement | 字符串 | |
| responseData | 物体 | 包含该请求的实际响应有效负载 |
| 要求 | 对象数组 | |
| 搜索词 | 字符串数组 | |
| 简短描述 | 字符串 | |
| 子类别 | 字符串 | 请参阅下面的子类别列表 |
| supportContactInfo | 字符串 | |
| systemRequirementDetails | 对象数组 | |
| 目标 | 字符串 | 发生错误的实体 |
| 网站 | 字符串 | |
| whatsNew | 字符串 |
更新当前草稿提交元数据 API
更新草稿提交中所有模块的元数据。 API 检查
- 活动的提交。 如果存在,则失败并显示错误消息。
- 所有模块是否都处于允许保存草稿操作的就绪状态。
- 提交内容中的每个字段都按照商店的要求进行了验证
- 系统需求详情验证规则:
- hardwareItemType 中的允许值 = Memory:300MB、750MB、1GB、2GB、4GB、6GB、8GB、12GB、16GB、20GB
- hardwareItemType 中的允许值 = DirectX:DX9、DX10、DX11、DX12-FEATURELEVEL11、DX12-FEATURELEVEL12
- hardwareItemType 中的允许值 = Video_Memory:1GB、2GB、4GB、6GB
路径 [完整模块更新]: /submission/v1/product/{productId}/metadata
方法: PUT
路径 [模块更新]: /submission/v1/product/{productId}/metadata
方法:PATCH
API 行为
使用完整模块更新 API 时,所有模块数据都需要出现在请求中,以便完整更新每个字段。 未请求的字段默认值将覆盖该模块的当前值。
使用修补程序模块更新 API时,只有要更新的字段才需要出现在请求中。 请求到的字段值将覆盖其现有值,其他所有未在请求中出现的字段,将与该模块的当前字段相同。
路径参数
| 参数 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
在 Partner Center 帐户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
合作伙伴中心帐户的卖家 ID |
请求参数
| 名称 | 类型 | 说明 |
|---|---|---|
| 可用性 | 物体 | 用于保存可用性模块元数据的对象 |
| markets | 字符串数组 | 必填 请参阅下面的市场列表 |
| 可发现性 | 字符串 | 必需 [DISCOVERABLE, DEEPLINK_ONLY] |
| enableInFutureMarkets | 布尔 | 必需 |
| 定价 | 字符串 | 必需 [FREE, FREEMIUM, SUBSCRIPTION, PAID] |
| FreeTrial | 字符串 | 如果定价为 PAID 或 SUBSCRIPTION,则必需 [NO_FREE_TRIAL,FREE_TRIAL] |
| properties | 物体 | 用于保存属性模块元数据的对象 |
| isPrivacyPolicyRequired | 布尔 | 必需 |
| 隐私政策网址 | 字符串 | 如果 isPrivacyPolicyRequired = true,则为必填项必须是有效的 URL |
| 网站 | 字符串 | 必须是有效的 URI |
| supportContactInfo | 字符串 | 必须为有效的 URL 或电子邮件地址 |
| certificationNotes | 字符串 | 推荐 字符限制 = 2000 |
| 分类 | 字符串 | 必填 请参阅下面的类别列表 |
| 子类别 | 字符串 | 必填 请参阅下面的子类别列表 |
| 产品声明 | 物体 | 必需 |
| isSystemFeatureRequired | 对象数组 | [触摸、键盘、鼠标、相机、NFC_HCE、NFC_Proximity、Bluetooth_LE、电话、麦克风] |
| 是否必填 | 布尔 | 必需 |
| isRecommended | 布尔 | 必需 |
| hardwareItemType | 字符串 | 必需 |
| systemRequirementDetails | 对象数组 | [处理器、图形、内存、DirectX、Video_Memory] |
| minimumRequirement | 字符串 |
必填 对于 systemRequirementsText,最大长度 = 200 hardwareItemType 中的允许值 = 内存:[300MB、750MB、1GB、2GB、4GB、6GB、8GB、12GB、16GB、20GB] hardwareItemType 中的允许值 = DirectX:[DX9、DX10、DX11、DX12-FEATURELEVEL11、DX12-FEATURELEVEL12] hardwareItemType 中的允许值 = Video_Memory:[1GB、2GB、4GB、6GB] |
| recommendedRequirement | 字符串 |
必填 对于 systemRequirementsText,最大长度 = 200 hardwareItemType 中的允许值 = 内存:[300MB、750MB、1GB、2GB、4GB、6GB、8GB、12GB、16GB、20GB] hardwareItemType 中的允许值 = DirectX:[DX9、DX10、DX11、DX12-FEATURELEVEL11、DX12-FEATURELEVEL12] hardwareItemType 中的允许值 = Video_Memory:[1GB、2GB、4GB、6GB] |
| dependsOnDriversOrNT | 布尔 | 必需 |
| accessibilitySupport | 布尔 | 必需 |
| penAndInkSupport | 布尔 | 必需 |
| 清单 | 物体 | 用于列出单语言模块数据的对象 |
| 语言 | 字符串 | 必填 请参阅下面的语言列表 |
| description | 字符串 | 必填 字符限制 = 10000 |
| whatsNew | 字符串 | 字符限制:1500 |
| productFeatures | 字符串数组 | 每个功能 200 个字符;最多 20 个功能 |
| 简短描述 | 字符串 | 字符限制:1000 |
| 搜索词 | 字符串数组 | 每个搜索词 30 个字符;最多 7 个搜索词 所有搜索词中总计有 21 个唯一单词 |
| 附加许可条款 | 字符串 | 必填 字符限制 = 10000 |
| 版权 | 字符串 | 字符限制 = 200 |
| developedBy | 字符串 | 字符限制 = 255 |
| 要求 | 对象数组 | 每项 200 个字符;在最小值和推荐值之间共计不超过 11 项] |
| minimumHardware | 字符串 | 字符限制 = 200 |
| 推荐硬件 | 字符串 | 字符限制 = 200 |
| 联系信息 | 字符串 | 字符限制 = 200 |
| listingsToAdd | 字符串数组 | 查看语言列表 |
| listingsToRemove | 字符串数组 | 查看语言列表 |
市场
查看表
| 市场 | 缩写 | |--------|--------------| | Afghanistan | AF | | Albania | AL | | Algeria | DZ | | American Samoa | AS | | Andorra | AD | | Angola | AO | | Anguilla | AI | | Antarctica | AQ | | Antigua and Barbuda | AG | | Argentina | AR | | Armenia | AM | | Aruba | AW | | Australia | AU | | Austria | AT | | Azerbaijan | AZ | | Bahamas | BS | | Bahrain | BH | | Bangladesh | BD | | Barbados | BB | | Belarus | BY | | Belgium | BE | | Belize | BZ | | Benin | BJ | | Bermuda | BM | | Bhutan | BT | | Bolivarian Republic of Venezuela | VE | | Bolivia | BO | | Bonaire | BQ | | Bosnia and Herzegovina | BA | | Botswana | BW | | Bouvet Island | BV | | Brazil | BR | | British Indian Ocean Territory | IO | | British Virgin Islands | VG | | Brunei | BN | | Bulgaria | BG | | Burkina Faso | BF | | Burundi | BI | | Cambodia | KH | | Cameroon | CM | | Canada | CA | | Cabo Verde | CV | | Cayman Islands | KY | | Central African Republic | CF | | Chad | TD | | Chile | CL | | China | CN | | Christmas Island | CX | | Cocos (Keeling) Islands | CC | | Colombia | CO | | Comoros | KM | | Congo | CG | | Congo (DRC) | CD | | Cook Islands | CK | | Costa Rica | CR | | Croatia | HR | | Curaçao | CW | | Cyprus | CY | | Czech Republic | CZ | | Côte d'Ivoire | CI | | Denmark | DK | | Djibouti | DJ | | Dominica | DM | | Dominican Republic | DO | | Ecuador | EC | | Egypt | EG | | El Salvador | SV | | Equatorial Guinea | GQ | | Eritrea | ER | | Estonia | EE | | Ethiopia | ET | | Falkland Islands | FK | | Faroe Islands | FO | | Fiji | FJ | | Finland | FI | | France | FR | | French Guiana | GF | | French Polynesia | PF | | French Southern and Antarctic Lands | TF | | Gabon | GA | | Gambia | GM | | Georgia | GE | | Germany | DE | | Ghana | GH | | Gibraltar | GI | | Greece | GR | | Greenland | GL | | Grenada | GD | | Guadeloupe | GP | | Guam | GU | | Guatemala | GT | | Guernsey | GG | | Guinea | GN | | Guinea-Bissau | GW | | Guyana | GY | | Haiti | HT | | Heard Island and McDonald Islands | HM | | Vatican City | VA | | Honduras | HN | | Hong Kong SAR | HK | | Hungary | HU | | Iceland | IS | | India | IN | | Indonesia | ID | | Iraq | IQ | | Ireland | IE | | Israel | IL | | Italy | IT | | Jamaica | JM | | Japan | JP | | Jersey | JE | | Jordan | JO | | Kazakhstan | KZ | | Kenya | KE | | Kiribati | KI | | Korea | KR | | Kuwait | KW | | Kyrgyzstan | KG | | Laos | LA | | Latvia | LV | | Lebanon | LB | | Lesotho | LS | | Liberia | LR | | Libya | LY | | Liechtenstein | LI | | Lithuania | LT | | Luxembourg | LU | | Macao SAR | MO | | North Macedonia | MK | | Madagascar | MG | | Malawi | MW | | Malaysia | MY | | Maldives | MV | | Mali | ML | | Malta | MT | | Isle of Man | IM | | Marshall Islands | MH | | Martinique | MQ | | Mauritania | MR | | Mauritius | MU | | Mayotte | YT | | Mexico | MX | | Micronesia | FM | | Moldova | MD | | Monaco | MC | | Mongolia | MN | | Montenegr - ME | | Montserrat | MS | | Morocco | MA | | Mozambique | MZ | | Myanmar | MM | | Namibia | NA | | Nauru | NR | | Nepal | NP | | Netherlands | NL | | New Caledonia | NC | | New Zealand | NZ | | Nicaragua | NI | | Niger | NE | | Nigeria | NG | | Niue | NU | | Norfolk Island | NF | | Northern Mariana Islands | MP | | Norway | NO | | Oman | OM | | Pakistan | PK | | Palau | PW | | Palestinian Authority | PS | | Panama | PA | | Papua New Guinea | PG | | Paraguay | PY | | Peru | PE | | Philippines | PH | | Pitcairn Islands | PN | | Poland | PL | | Portugal | PT | | Qatar | QA | | Reunion | RE | | Romania | RO | | Russia | RU | | Rwanda | RW | | Saint Barthélemy | BL | | Saint Helena, Ascension and Tristan da Cunha | SH | | Saint Kitts and Nevis | KN | | Saint Lucia | LC | | Saint Martin (French Part) | MF | | Saint Pierre and Miquelon | PM | | Saint Vincent and the Grenadines | VC | | Samoa | WS | | San Marino | SM | | Saudi Arabia | SA | | Senegal | SN | | Serbia | RS | | Seychelles | SC | | Sierra Leone | SL | | Singapore | SG | | Sint Maarten (Dutch Part) | SX | | Slovakia | SK | | Slovenia | SI | | Solomon Islands | SB | | Somalia | SO | | South Africa | ZA | | South Georgia and the South Sandwich Islands | GS | | Spain | ES | | Sri Lanka | LK | | Suriname | SR | | Svalbard and Jan Mayen | SJ | | Swaziland | SZ | | Sweden | SE | | Switzerland | CH | | São Tomé and Príncipe | ST | | Taiwan | TW | | Tajikistan | TJ | | Tanzania | TZ | | Thailand | TH | | Timor-Leste | TL | | Tog - TG | | Tokelau | TK | | Tonga | TO | | Trinidad and Tobag - TT | | Tunisia | TN | | Türkiye | TR | | Turkmenistan | TM | | Turks and Caicos Islands | TC | | Tuvalu | TV | | U.S. Minor Outlying Islands | UM | | U.S. Virgin Islands | VI | | Uganda | UG | | Ukraine | UA | | United Arab Emirates | AE | | United Kingdom | GB | | 美国 | US | | Uruguay | UY | | Uzbekistan | UZ | | Vanuatu | VU | | Vietnam | VN | | Wallis and Futuna | WF | | Yemen | YE | | Zambia | ZM | | Zimbabwe | ZW | | Åland Islands | AX |类别和子类别
查看表
| 类别 | 子类别 | |-----------------------|---------------| | BooksAndReference | EReader, Fiction, Nonfiction, Reference | | Business | AccountingAndfinance, Collaboration, CRM, DataAndAnalytics, FileManagement, InventoryAndlogistics, LegalAndHR, ProjectManagement, RemoteDesktop, SalesAndMarketing, TimeAndExpenses | | DeveloperTools | Database, DesignTools, DevelopmentKits, Networking, ReferenceAndTraining, Servers, Utilities, WebHosting | Education | EducationBooksAndReference, EarlyLearning, InstructionalTools, Language, StudyAids | | Entertainment |(无)| | FoodAndDining |(无)| | GovernmentAndPolitics |(无)| | HealthAndFitness |(无)| | KidsAndFamily | KidsAndFamilyBooksAndReference, KidsAndFamilyEntertainment, HobbiesAndToys, SportsAndActivities, KidsAndFamilyTravel | | Lifestyle | Automotive, DYI, HomeAndGarden, Relationships, SpecialInterest, StyleAndFashion | | Medical |(无)| | MultimediaDesign | IllustrationAndGraphicDesign, MusicProduction, PhotoAndVideoProduction | | Music |(无)| | NavigationAndMaps |(无)| | NewsAndWeather | News, Weather | | PersonalFinance | BankingAndInvestments, BudgetingAndTaxes | | Personalization | RingtonesAndSounds, themes, WallpaperAndLockScreens | | PhotoAndVideo |(无)| | Productivity |(无)| | Security | PCProtection, PersonalSecurity | | Shopping |(无)| | Social |(无)| | Sports |(无)| | Travel | CityGuides, Hotels | | UtilitiesAndTools | BackupAndManage, FileManager |语言
查看表
| 语言名称 | 支持的语言代码 | |---------------|--------------------------| | Afrikaans | af, af-za | | Albanian | sq, sq-al | | Amharic | am, am-et | | Armenian | hy, hy-am | | Assamese | as, as-in | | Azerbaijani | az-arab, az-arab-az, az-cyrl, az-cyrl-az, az-latn, az-latn-az | | Basque (Basque) | eu, eu-es | | Belarusian | be, be-by | | Bangla | bn, bn-bd, bn-in | | Bosnian | bs, bs-cyrl, bs-cyrl-ba, bs-latn, bs-latn-ba | | Bulgarian | bg, bg-bg | | Catalan | ca, ca-es, ca-es-valencia | | Cherokee | chr-cher, chr-cher-us, chr-latn | | 简体中文 | zh-Hans, zh-cn, zh-hans-cn, zh-sg, zh-hans-sg | | 繁体中文 | zh-Hant, zh-hk, zh-mo, zh-tw, zh-hant-hk, zh-hant-mo, zh-hant-tw, zh-mo, zh-tw, zh-hant-hk, zh-hant-mo, zh-hant-tw | | Croatian | hr, hr-hr, hr-ba | | Czech | cs, cs-cz | | Danish | da, da-dk | | Dari | prs, prs-af, prs-arab | | Dutch | nl, nl-nl, nl-be | | English | en, en-au, en-ca, en-gb, en-ie, en-in, en-nz, en-sg, en-us, en-za, en-bz, en-hk, en-id, en-jm, en-kz, en-mt, en-my, en-ph, en-pk, en-tt, en-vn, en-zw | | Estonian | et, et-ee | | Filipin - fil, fil-latn, fil-ph | | Finnish | fi, fi-fi | | French | fr, fr-be , fr-ca , fr-ch , fr-fr , fr-lu, fr-cd, fr-ci, fr-cm, fr-ht, fr-ma, fr-mc, fr-ml, fr-re, frc-latn, frp-latn | | Galician | gl, gl-es | | Georgian | ka, ka-ge | | German | de, de-at, de-ch, de-de, de-lu, de-li | | Greek | el, el-gr | | Gujarati | gu, gu-in | | Hausa | ha, ha-latn, ha-latn-ng | | Hebrew | he, he-il | | Hindi | hi, hi-in | | Hungarian | hu, hu-hu | | Icelandic | is, is-is | | Igb - ig-latn, ig-ng | | Indonesian | id, id-id | | Inuktitut (Latin) | iu-cans, iu-latn, iu-latn-ca | | Irish | ga, ga-ie | | isiXhosa | xh, xh-za | | isiZulu | zu, zu-za | | Italian | it, it-it, it-ch | | Japanese | ja , ja-jp | | Kannada | kn, kn-in | | Kazakh | kk, kk-kz | | Khmer | km, km-kh | | K'iche' | quc-latn, qut-gt, qut-latn | | Kinyarwanda | rw, rw-rw | | KiSwahili | sw, sw-ke | | Konkani | kok, kok-in | | Korean | ko, ko-kr | | Kurdish | ku-arab, ku-arab-iq | | Kyrgyz | ky-kg, ky-cyrl | | Lao | lo, lo-la | | Latvian | lv, lv-lv | | Lithuanian | lt, lt-lt | | Luxembourgish | lb, lb-lu | | Macedonian | mk, mk-mk | | Malay | ms, ms-bn, ms-my | | Malayalam | ml, ml-in | | Maltese | mt, mt-mt | | Maori | mi, mi-latn, mi-nz | | Marathi | mr, mr-in | | Mongolian (Cyrillic) | mn-cyrl, mn-mong, mn-mn, mn-phag | | Nepali | ne, ne-np | | Norwegian | nb, nb-no, nn, nn-no, no, no-no | | Odia | or, or-in | | Persian | fa, fa-ir | | Polish | pl, pl-pl | | Portuguese (Brazil) | pt-br | | Portuguese (Portugal) | pt, pt-pt | | Punjabi | pa, pa-arab, pa-arab-pk, pa-deva, pa-in | | Quechua | quz, quz-bo, quz-ec, quz-pe | | Romanian | ro, ro-ro | | Russian | ru , ru-ru | | Scottish Gaelic | gd-gb, gd-latn | | Serbian (Latin) | sr-Latn, sr-latn-cs, sr, sr-latn-ba, sr-latn-me, sr-latn-rs | | Serbian (Cyrillic) | sr-cyrl, sr-cyrl-ba, sr-cyrl-cs, sr-cyrl-me, sr-cyrl-rs | | Sesotho sa Leboa | nso, nso-za | | Setswana | tn, tn-bw, tn-za | | Sindhi | sd-arab, sd-arab-pk, sd-deva | | Sinhala | si, si-lk | | Slovak | sk, sk-sk | | Slovenian | sl, sl-si | | Spanish | es, es-cl, es-co, es-es, es-mx, es-ar, es-bo, es-cr, es-do, es-ec, es-gt, es-hn, es-ni, es-pa, es-pe, es-pr, es-py, es-sv, es-us, es-uy, es-ve | | Swedish | sv, sv-se, sv-fi | | Tajik (Cyrillic) | tg-arab, tg-cyrl, tg-cyrl-tj, tg-latn | | Tamil | ta, ta-in | | Tatar | tt-arab, tt-cyrl, tt-latn, tt-ru | | Telugu | te, te-in | | Thai | th, th-th | | Tigrinya | ti, ti-et | | Turkish | tr, tr-tr | | Turkmen | tk-cyrl, tk-latn, tk-tm, tk-latn-tr, tk-cyrl-tr | | Ukrainian | uk, uk-ua | | Urdu | ur, ur-pk | | Uyghur | ug-arab, ug-cn, ug-cyrl, ug-latn | | Uzbek (Latin) | uz, uz-cyrl, uz-latn, uz-latn-uz | | Vietnamese | vi, vi-vn | | Welsh | cy, cy-gb | | Wolof | wo, wo-sn | | Yoruba | yo-latn, yo-ng |示例请求
{
"availability":{
"markets": ["US"],
"discoverability": "DISCOVERABLE",
"enableInFutureMarkets": true,
"pricing": "PAID",
"freeTrial": "NO_FREE_TRIAL"
},
"properties":{
"isPrivacyPolicyRequired": true,
"privacyPolicyUrl": "http://contoso.com",
"website": "http://contoso.com",
"supportContactInfo": "http://contoso.com",
"certificationNotes": "Certification Notes",
"category": "DeveloperTools",
"subcategory": "Database",
"productDeclarations": {
"dependsOnDriversOrNT": false,
"accessibilitySupport": false,
"penAndInkSupport": false
},
"isSystemFeatureRequired": [
{
"isRequired": true,
"isRecommended": false,
"hardwareItemType": "Touch"
},
{
"isRequired": true,
"isRecommended": false,
"hardwareItemType": "Keyboard"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "Mouse"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "Camera"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "NFC_HCE"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "NFC_Proximity"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "Bluetooth_LE"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "Telephony"
},
{
"isRequired": false,
"isRecommended": false,
"hardwareItemType": "Microphone"
}
],
"systemRequirementDetails": [
{
"minimumRequirement": "1GB",
"recommendedRequirement": "4GB",
"hardwareItemType": "Memory"
},
{
"minimumRequirement": "",
"recommendedRequirement": "",
"hardwareItemType": "DirectX"
},
{
"minimumRequirement": "",
"recommendedRequirement": "",
"hardwareItemType": "Video_Memory"
},
{
"minimumRequirement": "",
"recommendedRequirement": "",
"hardwareItemType": "Processor"
},
{
"minimumRequirement": "",
"recommendedRequirement": "",
"hardwareItemType": "Graphics"
}
]
},
"listings":{
"language": "en-us",
"description": "Description",
"whatsNew": "What's New",
"productFeatures": ["Feature 1"],
"shortDescription": "Short Description",
"searchTerms": ["Search Ter 1"],
"additionalLicenseTerms": "License Terms",
"copyright": "Copyright Information",
"developedBy": "Developer Details",
"sortTitle": "Product 101",
"requirements": [
{
"minimumHardware": "Pentium4",
"recommendedHardware": "Corei9"
}
],
"contactInfo": "contactus@contoso.com"
},
"listingsToAdd": ["en-au"],
"listingsToRemove": ["en-gb"]
}
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位) |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | 包含该请求的实际响应有效负载 |
| pollingUrl | 字符串 | 轮询 URL 以获取进行中的提交所处状态 |
| ongoingSubmissionId | 字符串 | 进行中的提交的提交 ID |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"pollingUrl": "/submission/v1/product/{productId}/submission/{submissionId}/status",
"ongoingSubmissionId": ""
}
}
获取当前草稿包 API
提取当前草稿提交的包详情。
路径 [所有包]: /submission/v1/product/{productId}/packages
方法:GET
路径 [单包]: /submission/v1/product/{productId}/packages/{packageId}
方法:GET
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
| 包 ID | 要提取包的唯一 ID |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| 软件包 | 对象数组 | 用于保存包模块数据的对象 |
| 包 ID | 字符串 | |
| packageUrl | 字符串 | |
| 语言 | 字符串数组 | |
| architectures | 字符串数组 | [Neutral, X86, X64, Arm, Arm64] |
| isSilentInstall | 布尔 | 如果安装程序以静默模式运行,而无需切换,则应将此项标记为 true,否则为 false |
| installerParameters | 字符串 | |
| genericDocUrl | 字符串 | |
| errorDetails | 对象数组 | |
| errorScenario | 字符串 | |
| errorScenarioDetails | 对象数组 | |
| errorValue | 字符串 | |
| errorUrl | 字符串 | |
| 包裹类型 | 字符串 |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData":{
"packages":[{
"packageId": "pack0832",
"packageUrl": "https://www.contoso.com/downloads/1.1/setup.exe",
"languages": ["en-us"],
"architectures": ["X86"],
"isSilentInstall": true,
"installerParameters": "/s",
"genericDocUrl": "https://docs.contoso.com/doclink",
"errorDetails": [{
"errorScenario": "rebootRequired",
"errorScenarioDetails": [{
"errorValue": "ERR001001",
"errorUrl": "https://errors.contoso.com/errors/ERR001001"
}]
}],
"packageType": "exe",
}]
}
}
更新当前草稿包 API
更新当前草稿提交中的软件包详情。
路径 [完整模块更新]: /submission/v1/product/{productId}/packages
方法:PUT
路径 [单个包修补程序更新]:/submission/v1/product/{productId}/packages/{packageId}
方法:PATCH
API 行为
使用完整模块更新 API 时,请求需要包括所有模块数据,以便完整更新每个字段。 对于请求中未提供的任何字段,都会使用其默认值覆盖该特定模块的当前值。 这会使请求的新包集覆盖所有现有包。 这将导致包 ID 重新生成,用户应调用 GET Packages API 以获取最新的包 ID。
使用单包程序模块更新 API 时,只有给定包中需更新的字段才需要在请求中出现。 请求到的字段值将覆盖其现有值,其他所有未在请求中出现的字段,将与该包的当前字段相同。 集合中的其他包保持不变。
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
| 包 ID | 包的唯一 ID |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
合作伙伴中心帐户的卖家 ID |
请求参数
| 名称 | 类型 | 说明 |
|---|---|---|
| 软件包 | 对象数组 | 用于保存包模块数据的对象 [仅在完整模块更新时需要] |
| packageUrl | 字符串 | 必需 |
| 语言 | 字符串数组 | 必需 |
| architectures | 字符串数组 | 必填 应包含单个体系结构 - 中性、X86、X64、Arm、Arm64 |
| isSilentInstall | 布尔 | 必填 如果安装程序以静默模式运行且不需要切换,则应将其标记为 true,否则标记为 false。 |
| installerParameters | 字符串 | 如果 isSilentInstall 为 false,则为必需 |
| genericDocUrl | 字符串 | 如果 packageType 为 exe,则为必需 指向包含 EXE 类型安装程序自定义错误代码详细信息的文档的链接 |
| errorDetails | 对象数组 | 用于保存 EXE 类型安装程序的自定义错误代码和详细信息的元数据。 |
| errorScenario | 字符串 | 确定具体错误发生的场景。 [用户取消安装, 应用程序已存在, 安装已在进行中, 磁盘空间已满, 需要重新启动, 网络故障, 安装过程中程序包被拒绝, 安装成功, 其他] |
| errorScenarioDetails | 对象数组 | |
| errorValue | 字符串 | 安装过程中可能出现的错误代码 |
| errorUrl | 字符串 | 包含错误详细信息的 URL |
| 包裹类型 | 字符串 | 必需 [exe, msi] |
示例请求 [完整模块更新]
{
"packages":[{
"packageUrl": "https://www.contoso.com/downloads/1.1/setup.exe",
"languages": ["en-us"],
"architectures": ["X86"],
"isSilentInstall": true,
"installerParameters": "/s",
"genericDocUrl": "https://docs.contoso.com/doclink",
"errorDetails": [{
"errorScenario": "rebootRequired",
"errorScenarioDetails": [{
"errorValue": "ERR001001",
"errorUrl": "https://errors.contoso.com/errors/ERR001001"
}]
}],
"packageType": "exe",
}]
}
示例请求 [单包补丁更新]
{
"packageUrl": "https://www.contoso.com/downloads/1.1/setup.exe",
"languages": ["en-us"],
"architectures": ["X86"],
"isSilentInstall": true,
"installerParameters": "/s",
"genericDocUrl": "https://docs.contoso.com/doclink",
"errorDetails": [{
"errorScenario": "rebootRequired",
"errorScenarioDetails": [{
"errorValue": "ERR001001",
"errorUrl": "https://errors.contoso.com/errors/ERR001001"
}]
}],
"packageType": "exe",
}
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | [错误或警告消息列表(如果有)] |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| pollingUrl | 字符串 | [轮询 URL 以获取进行中的提交所处状态] |
| ongoingSubmissionId | 字符串 | [进行中的提交的提交 ID] |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"pollingUrl": "/submission/v1/product/{productId}/submission/{submissionId}/status",
"ongoingSubmissionId": ""
}
}
提交软件包 API
在当前草稿提交基础上,使用 包更新 API 提交已更新的新包集。 该 API 返回一个轮询 URL,用于跟踪软件包上传状态。
路径:/submission/v1/product/{productId}/packages/commit
方法:POST
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | [错误或警告消息列表(如果有)] |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| pollingUrl | 字符串 | [轮询 URL 以进行中的提交的获取包上传状态或提交状态] |
| ongoingSubmissionId | 字符串 | [进行中的提交的提交 ID] |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"pollingUrl": "/submission/v1/product/{productId}/status",
"ongoingSubmissionId": ""
}
}
获取当前草稿列表资产 API
提取当前草稿提交的资产列表详情。
路径:/submission/v1/product/{productId}/listings/assets?languages={languages}
方法:GET
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
查询参数
| 名称 | 说明 |
|---|---|
| 语言 | [可选]:列表语言筛选器使用逗号分隔字符串 [最多 200 种语言]。 如果空置,将提取前 200 个可用的列表语言资产数据。 (例如“en-us, en-gb") |
必需标头
| 标头 | 值 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 值 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| listingAssets | 对象数组 | 列出每种语言的资产详细信息 |
| 语言 | 字符串 | |
| storeLogos | 对象数组 | |
| 屏幕截图 | 对象数组 | |
| ID | 字符串 | |
| assetUrl | 字符串 | 必须是有效的 URI |
| imageSize | 物体 | |
| 宽度 | 整数 | |
| height | 整数 |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData":{
"listingAssets": [{
"language": "en-us",
"storeLogos": [
{
"id": "1234567890abcdefgh",
"assetUrl": "https://contoso.com/blob=1234567890abcdefgh",
"imageSize": {
"width": 2160,
"height": 2160
}
}
],
"screenshots": [
{
"id": "1234567891abcdefgh",
"assetUrl": "https://contoso.com/blob=1234567891abcdefgh",
"imageSize": {
"width": 2160,
"height": 2160
}
}
]
}]
}
}
创建列出资产 API
在当前草稿提交基础上创建新的列表资产上传。
资产列表更新
适用于 EXE 或 MSI 应用的 Microsoft Store 提交 API 使用在运行时生成的、指向 Blob 存储的 SAS URL 来上传每个单独的图像资产,并在上传成功后调用 Commit API。 如果要能够更新列表资产,反之,要能够在列表模块中添加/删除区域设置,可以使用以下方法:
- 使用创建列表资产 API 发送有关资产上传的请求以及语言、类型和资产计数。
- 资产 ID 会根据请求的资产数按需创建,短期 SAS URL 也将在创建后以资产类型按照正文格式回传。 可以使用此 URL 通过 HTTP 客户端上传特定类型的图像资产 [Put Blob (REST API) - Azure 存储 |Microsoft Docs]。
- 上传后,您还可以使用 Commit Listing Assets API 发送此前通过上一次 API 调用收到的新 Asset ID 信息。 该 API 会在验证通过后内部提交资产列表数据。
- 特定语言(已在请求中发送)的资产类型下的所有旧图片集,可由此方法有效覆盖。 因此,以前上传的资产将被删除。
路径:/submission/v1/product/{productId}/listings/assets/create
方法:POST
路径参数
| 名称 | 说明 |
|---|---|
| productId | 该产品的合作伙伴中心 ID |
必需标头
| 标头 | 说明 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
合作伙伴中心帐户的卖家 ID |
请求参数
| 名称 | 类型 | 说明 |
|---|---|---|
| 语言 | 字符串 | 必需 |
| createAssetRequest | 物体 | 必需 |
| 屏幕快照 | 整数 | ISV 需要更新屏幕截图或添加新列表语言 [1 - 10] 时是必需的 |
| 徽标 | 整数 | 如果 ISV 需要更新徽标或添加新列表语言,则为必需 [1 或 2] |
响应标头
| 标头 | 说明 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| listingAssets | 物体 | 包含待上传的商店徽标和屏幕截图详细信息的对象 |
| 语言 | 字符串 | |
| 商店徽标 | 对象数组 | |
| 屏幕截图 | 对象数组 | |
| ID | 字符串 | |
| primaryAssetUploadUrl | 字符串 | 使用 Azure Blob REST API 上传列表资产的主要 URL |
| secondaryAssetUploadUrl | 字符串 | 使用 Azure Blob REST API 上传列表资源的次要 URL |
| HTTP方法 | HTTP 方法 | 需要使用 HTTP 方法通过资产上传 URL 上传资产(主要或次要) |
| httpHeaders | 物体 | 对象的键作为资产上传 URL 的调用上传 API 时。 如果值不为空,标头需要具有特定值。 否则,值将在 API 调用期间计算。 |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"listingAssets": {
"language": "en-us",
"storeLogos":[{
"id": "1234567890abcdefgh",
"primaryAssetUploadUrl": "https://contoso.com/upload?blob=1234567890abcdefgh&sig=12345",
"secondaryAssetUploadUrl": "https://contoso.com/upload?blob=0987654321abcdfger&sig=54326",
"httpMethod": "PUT",
"httpHeaders": {"Required Header Name": "Header Value"}
}],
"screenshots":[{
"id": "0987654321abcdfger",
"primaryAssetUploadUrl": "https://contoso.com/upload?blob=0987654321abcdfger&sig=54321",
"secondaryAssetUploadUrl": "https://contoso.com/upload?blob=0987654321abcdfger&sig=54322",
"httpMethod": "PUT",
"httpHeaders": {"Required Header Name": "Header Value"}
}]
}
}
}
提交资产列表 API
在当前草稿提交基础上,使用创建资产 API 提交新的已上传列表资产。
路径:/submission/v1/product/{productId}/listings/assets/commit
方法:PUT
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 说明 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
请求参数
| 名称 | 类型 | 说明 |
|---|---|---|
| listingAssets | 物体 | |
| 语言 | 字符串 | |
| 店铺徽标 | 对象数组 | |
| 屏幕截图 | 对象数组 | |
| ID | 字符串 | 应为用户希望从 Get Current Listing Assets API 中保留的现有 ID,或者是在 Create Listing Assets API 中上传新资产时使用的新 ID。 |
| assetUrl | 字符串 | 应为以下两者之一:通过 Get Current Listing Assets API 获取的、用户希望保留的现有资产 URL,或在 Create Listing Assets API 中用于上传新资产的上传 URL(主上传 URL 或次上传 URL)。 必须是有效的 URI |
示例请求
{
"listingAssets": {
"language": "en-us",
"storeLogos": [
{
"id": "1234567890abcdefgh",
"assetUrl": "https://contoso.com/blob=1234567890abcdefgh",
}
],
"screenshots": [
{
"id": "1234567891abcdefgh",
"assetUrl": "https://contoso.com/blob=1234567891abcdefgh",
}
]
}
}
响应标头
| 标头 | 说明 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| pollingUrl | 字符串 | 轮询 URL 以获取进行中的提交所处状态 |
| ongoingSubmissionId | 字符串 | 进行中的提交的提交 ID |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"pollingUrl": "/submission/v1/product/{productId}/submission/{submissionId}/status",
"ongoingSubmissionId": ""
}
}
模块状态轮询 API
可以创建一个 API,用于在提交前检查模块是否已就绪。 还会验证软件包上传状态。
路径:/submission/v1/product/{productId}/status
方法:GET
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 说明 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 账户的卖家 ID |
响应标头
| 标头 | 说明 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| isReady | 布尔 | 表明是否所有模块已处于就绪状态,包括包上传 |
| ongoingSubmissionId | 字符串 | 进行中的提交的提交 ID |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"isReady": true,
"ongoingSubmissionId": ""
}
}
创建提交 API
从当前 MSI 或 EXE 应用的草稿创建提交。 API 将检查:
- 活动提交,如果存在活动提交,则失败并显示错误消息。
- 是否所有模块都处于可创建提交的就绪状态。
- 提交内容中的每个字段都按照应用商店的要求进行了验证
路径:/submission/v1/product/{productId}/submit
方法:POST
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 说明 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 说明 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| pollingUrl | 字符串 | 轮询 URL 以获取模块准备状态,包括提交包上传 |
| submissionId | 字符串 | 新建提交的 ID |
| ongoingSubmissionId | 字符串 | 进行中的提交的提交 ID |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"submissionId": "1234567890",
"pollingUrl": "/submission/v1/product/{productId}/submission/{submissionId}/status",
"ongoingSubmissionId": ""
}
}
提交状态轮询 API
用于检查提交状态的 API。
路径:/submission/v1/product/{productId}/submission/{submissionId}/status
方法:GET
路径参数
| 名称 | 说明 |
|---|---|
| productId | 产品的合作伙伴中心 ID |
必需标头
| 标头 | 说明 |
|---|---|
Authorization: Bearer <Token> |
使用在“合作伙伴中心”账户中注册的 Microsoft Entra ID 应用 ID |
X-Seller-Account-Id |
Partner Center 帐户的卖家 ID |
响应标头
| 标头 | 说明 |
|---|---|
X-Correlation-ID |
每个请求都应该使用唯一的 GUID。 可以将其与支持团队共享以用于分析问题。 |
Retry-After |
由于速率限制,客户端在再次调用 API 之前需要等待的时间(以秒为单位)。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| isSuccess | 布尔 | |
| 错误 | 对象数组 | 错误或警告消息列表(如果有) |
| 代码 | 字符串 | 消息的错误代码 |
| 消息 | 字符串 | 对错误的说明 |
| 目标 | 字符串 | 发生错误的实体 |
| responseData | 物体 | |
| publishingStatus | 字符串 | 提交发布状态 - [INPROGRESS, PUBLISHED, FAILED, UNKNOWN] |
| hasFailed | 布尔 | 说明发布是否失败且不会重试 |
示例响应
{
"isSuccess": true,
"errors": [{
"code": "badrequest",
"message": "Error Message 1",
"target": "listings"
}, {
"code": "warning",
"message": "Warning Message 1",
"target": "properties"
}],
"responseData": {
"publishingStatus": "INPROGRESS",
"hasFailed": false
}
}
代码示例
下文中提供了详细的代码示例,演示了如何用不同的编程语言 使用 Microsoft Store 提交 API:
C# 示例:适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API
本文提供 C# 代码示例,演示如何使用适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API 执行以下任务。 你可以查看每个示例,了解有关它所演示的任务的详细信息,也可以将本文中的所有代码示例生成到控制台应用程序。
先决条件 这些示例使用以下库:
- 来自 Newtonsoft 的 Newtonsoft.Json NuGet 包。
主程序 以下示例实现一个命令行程序,该程序调用本文中的其他示例方法,以演示使用 Microsoft Store 提交 API 的不同方法。 要调整此代码以供自己使用,请执行以下操作:
- 将 SellerId 属性设置为你的 Partner Center 帐户的卖家 ID。
- 将 ApplicationId 属性分配给需要管理的应用ID。
- 将 ClientId 和 ClientSecret 属性分配给应用的客户端 ID 和密钥,并将 TokenEndpoint URL 中的 tenantid 字符串替换为应用的租户 ID。 有关详细信息,请参阅如何将 Microsoft Entra ID 应用程序与合作伙伴中心帐户相关联
using System;
using System.Threading.Tasks;
namespace Win32SubmissionApiCSharpSample
{
public class Program
{
static async Task Main(string[] args)
{
var config = new ClientConfiguration()
{
ApplicationId = "...",
ClientId = "...",
ClientSecret = "...",
Scope = "https://api.store.microsoft.com/.default",
ServiceUrl = "https://api.store.microsoft.com",
TokenEndpoint = "...",
SellerId = 0
};
await new AppSubmissionUpdateSample(config).RunAppSubmissionUpdateSample();
}
}
}
使用 C# 编写的 ClientConfiguration 辅助类
示例应用使用 ClientConfiguration 帮助程序类将 Microsoft Entra ID Directory 数据和应用数据传递给使用 Microsoft 应用商店提交 API 的每个示例方法。
using System;
using System.Collections.Generic;
using System.Text;
namespace Win32SubmissionApiCSharpSample
{
public class ClientConfiguration
{
/// <summary>
/// Client Id of your Microsoft Entra ID Directory app.
/// Example" 00001111-aaaa-2222-bbbb-3333cccc4444
/// </summary>
public string ClientId { get; set; }
/// <summary>
/// Client secret of your Microsoft Entra ID Directory app
/// </summary>
public string ClientSecret { get; set; }
/// <summary>
/// Service root endpoint.
/// Example: "https://api.store.microsoft.com"
/// </summary>
public string ServiceUrl { get; set; }
/// <summary>
/// Token endpoint to which the request is to be made. Specific to your Microsoft Entra ID Directory app
/// Example: https://login.microsoftonline.com/d454d300-128e-2d81-334a-27d9b2baf002/oauth2/v2.0/token
/// </summary>
public string TokenEndpoint { get; set; }
/// <summary>
/// Resource scope. If not provided (set to null), default one is used for the production API
/// endpoint ("https://api.store.microsoft.com/.default")
/// </summary>
public string Scope { get; set; }
/// <summary>
/// Partner Center Application ID.
/// Example: 3e31a9f9-84e8-4d2d-9eba-487878d02ebf
/// </summary>
public string ApplicationId { get; set; }
/// <summary>
/// The Partner Center Seller Id
/// Example: 123456892
/// </summary>
public int SellerId { get; set; }
}
}
使用 C# 创建应用提交
以下示例使用的类调用了 Microsoft Store 提交 API 中的多个方法以更新应用提交。
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Win32SubmissionApiCSharpSample
{
public class AppSubmissionUpdateSample
{
private ClientConfiguration ClientConfig;
/// <summary>
/// Constructor
/// </summary>
/// <param name="configuration">An instance of ClientConfiguration that contains all parameters populated</param>
public AppSubmissionUpdateSample(ClientConfiguration configuration)
{
this.ClientConfig = configuration;
}
/// <summary>
/// Main method to Run the Sample Application
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public async Task RunAppSubmissionUpdateSample()
{
// **********************
// SETTINGS
// **********************
var appId = this.ClientConfig.ApplicationId;
var clientId = this.ClientConfig.ClientId;
var clientSecret = this.ClientConfig.ClientSecret;
var serviceEndpoint = this.ClientConfig.ServiceUrl;
var tokenEndpoint = this.ClientConfig.TokenEndpoint;
var scope = this.ClientConfig.Scope;
// Get authorization token.
Console.WriteLine("Getting authorization token");
var accessToken = await SubmissionClient.GetClientCredentialAccessToken(
tokenEndpoint,
clientId,
clientSecret,
scope);
var client = new SubmissionClient(accessToken, serviceEndpoint);
client.DefaultHeaders = new Dictionary<string, string>()
{
{"X-Seller-Account-Id", this.ClientConfig.SellerId.ToString() }
};
Console.WriteLine("Getting Current Application Draft Status");
dynamic AppDraftStatus = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.ProductDraftStatusPollingUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(AppDraftStatus.ToString());
Console.WriteLine("Getting Application Packages ");
dynamic PackagesResponse = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.PackagesUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(PackagesResponse.ToString());
Console.WriteLine("Getting Single Package");
dynamic SinglePackageResponse = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.PackageByIdUrlTemplate,
SubmissionClient.Version, appId, (string)PackagesResponse.responseData.packages[0].packageId), null);
Console.WriteLine(SinglePackageResponse.ToString());
Console.WriteLine("Updating Entire Package Set");
// Update data in Packages list to have final set of updated Packages
// Example - Updating Installer Parameters
PackagesResponse.responseData.packages[0].installerParameters = "/s /r new-args";
dynamic PackagesUpdateRequest = new
{
packages = PackagesResponse.responseData.packages
};
dynamic PackagesUpdateResponse = await client.Invoke<dynamic>(HttpMethod.Put, string.Format(SubmissionClient.PackagesUrlTemplate,
SubmissionClient.Version, appId), PackagesUpdateRequest);
Console.WriteLine(PackagesUpdateResponse.ToString());
Console.WriteLine("Updating Single Package's Download Url");
// Update data in the SinglePackage object
var SinglePackageUpdateRequest = SinglePackageResponse.responseData.packages[0];
// Example - Updating Installer Parameters
SinglePackageUpdateRequest.installerParameters = "/s /r /t new-args";
dynamic PackageUpdateResponse = await client.Invoke<dynamic>(HttpMethod.Patch, string.Format(SubmissionClient.PackageByIdUrlTemplate,
SubmissionClient.Version, appId, SinglePackageUpdateRequest.packageId), SinglePackageUpdateRequest);
Console.WriteLine("Committing Packages");
dynamic PackageCommitResponse = await client.Invoke<dynamic>(HttpMethod.Post, string.Format(SubmissionClient.PackagesCommitUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(PackageCommitResponse.ToString());
Console.WriteLine("Polling Package Upload Status");
AppDraftStatus = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.ProductDraftStatusPollingUrlTemplate,
SubmissionClient.Version, appId), null);
while (!((bool)AppDraftStatus.responseData.isReady))
{
AppDraftStatus = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.ProductDraftStatusPollingUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine("Waiting for Upload to finish");
await Task.Delay(TimeSpan.FromSeconds(2));
if(AppDraftStatus.errors != null && AppDraftStatus.errors.Count > 0)
{
for(var index = 0; index < AppDraftStatus.errors.Count; index++)
{
if(AppDraftStatus.errors[index].code == "packageuploaderror")
{
throw new InvalidOperationException("Package Upload Failed. Please try committing packages again.");
}
}
}
}
Console.WriteLine("Getting Application Metadata - All Modules");
dynamic AppMetadata = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.AppMetadataUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(AppMetadata.ToString());
Console.WriteLine("Getting Application Metadata - Listings");
dynamic AppListingsMetadata = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.AppListingsFetchMetadataUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(AppListingsMetadata.ToString());
Console.WriteLine("Updating Listings Metadata - Description");
// Update Required Fields in Listings Metadata Object - Per Language. For eg. AppListingsMetadata.responseData.listings[0]
// Example - Updating Description
AppListingsMetadata.responseData.listings[0].description = "New Description Updated By C# Sample Code";
dynamic ListingsUpdateRequest = new
{
listings = AppListingsMetadata.responseData.listings[0]
};
dynamic UpdateListingsMetadataResponse = await client.Invoke<dynamic>(HttpMethod.Put, string.Format(SubmissionClient.AppMetadataUrlTemplate,
SubmissionClient.Version, appId), ListingsUpdateRequest);
Console.WriteLine(UpdateListingsMetadataResponse.ToString());
Console.WriteLine("Getting All Listings Assets");
dynamic ListingAssets = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.ListingAssetsUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(ListingAssets.ToString());
Console.WriteLine("Creating Listing Assets for 1 Screenshot");
dynamic AssetCreateRequest = new
{
language = ListingAssets.responseData.listingAssets[0].language,
createAssetRequest = new Dictionary<string, int>()
{
{"Screenshot", 1 },
{"Logo", 0 }
}
};
dynamic AssetCreateResponse = await client.Invoke<dynamic>(HttpMethod.Post, string.Format(SubmissionClient.ListingAssetsCreateUrlTemplate,
SubmissionClient.Version, appId), AssetCreateRequest);
Console.WriteLine(AssetCreateResponse.ToString());
Console.WriteLine("Uploading Listing Assets");
// Path to PNG File to be Uploaded as Screenshot / Logo
var PathToFile = "./Image.png";
var AssetToUpload = File.OpenRead(PathToFile);
await client.UploadAsset(AssetCreateResponse.responseData.listingAssets.screenshots[0].primaryAssetUploadUrl.Value as string, AssetToUpload);
Console.WriteLine("Committing Listing Assets");
dynamic AssetCommitRequest = new
{
listingAssets = new
{
language = ListingAssets.responseData.listingAssets[0].language,
storeLogos = ListingAssets.responseData.listingAssets[0].storeLogos,
screenshots = JToken.FromObject(new List<dynamic>() { new
{
id = AssetCreateResponse.responseData.listingAssets.screenshots[0].id.Value as string,
assetUrl = AssetCreateResponse.responseData.listingAssets.screenshots[0].primaryAssetUploadUrl.Value as string
}
}.ToArray())
}
};
dynamic AssetCommitResponse = await client.Invoke<dynamic>(HttpMethod.Put, string.Format(SubmissionClient.ListingAssetsCommitUrlTemplate,
SubmissionClient.Version, appId), AssetCommitRequest);
Console.WriteLine(AssetCommitResponse.ToString());
Console.WriteLine("Getting Current Application Draft Status before Submission");
AppDraftStatus = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.ProductDraftStatusPollingUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(AppDraftStatus.ToString());
if (AppDraftStatus == null || !((bool)AppDraftStatus.responseData.isReady))
{
throw new InvalidOperationException("Application Current Status is not in Ready Status for All Modules");
}
Console.WriteLine("Creating Submission");
dynamic SubmissionCreationResponse = await client.Invoke<dynamic>(HttpMethod.Post, string.Format(SubmissionClient.CreateSubmissionUrlTemplate,
SubmissionClient.Version, appId), null);
Console.WriteLine(SubmissionCreationResponse.ToString());
Console.WriteLine("Current Submission Status");
dynamic SubmissionStatus = await client.Invoke<dynamic>(HttpMethod.Get, string.Format(SubmissionClient.SubmissionStatusPollingUrlTemplate,
SubmissionClient.Version, appId, SubmissionCreationResponse.responseData.submissionId.Value as string), null);
Console.Write(SubmissionStatus.ToString());
// User can Poll on this API to know if Submission Status is INPROGRESS, PUBLISHED or FAILED.
// This Process involves File Scanning, App Certification and Publishing and can take more than a day.
}
}
}
使用 C# 的 IngestionClient 帮助器类
IngestionClient 类提供了帮助程序方法,由本示例应用中的其他方法使用以完成以下任务:
- 获取Microsoft Entra ID 访问令牌,该令牌可用于调用 Microsoft 应用商店提交 API 中的方法。 获取令牌后,可以在 60 分钟的令牌有效期内,使用该令牌调用“Microsoft Store 提交 API”。 该令牌到期后,可以重新生成一个。
- 处理 Microsoft Store 提交 API 的 HTTP 请求。
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace Win32SubmissionApiCSharpSample
{
/// <summary>
/// This class is a proxy that abstracts the functionality of the API service
/// </summary>
public class SubmissionClient : IDisposable
{
public static readonly string Version = "1";
private HttpClient httpClient;
private HttpClient imageUploadClient;
private readonly string accessToken;
public static readonly string PackagesUrlTemplate = "/submission/v{0}/product/{1}/packages";
public static readonly string PackageByIdUrlTemplate = "/submission/v{0}/product/{1}/packages/{2}";
public static readonly string PackagesCommitUrlTemplate = "/submission/v{0}/product/{1}/packages/commit";
public static readonly string AppMetadataUrlTemplate = "/submission/v{0}/product/{1}/metadata";
public static readonly string AppListingsFetchMetadataUrlTemplate = "/submission/v{0}/product/{1}/metadata/listings";
public static readonly string ListingAssetsUrlTemplate = "/submission/v{0}/product/{1}/listings/assets";
public static readonly string ListingAssetsCreateUrlTemplate = "/submission/v{0}/product/{1}/listings/assets/create";
public static readonly string ListingAssetsCommitUrlTemplate = "/submission/v{0}/product/{1}/listings/assets/commit";
public static readonly string ProductDraftStatusPollingUrlTemplate = "/submission/v{0}/product/{1}/status";
public static readonly string CreateSubmissionUrlTemplate = "/submission/v{0}/product/{1}/submit";
public static readonly string SubmissionStatusPollingUrlTemplate = "/submission/v{0}/product/{1}/submission/{2}/status";
public const string JsonContentType = "application/json";
public const string PngContentType = "image/png";
public const string BinaryStreamContentType = "application/octet-stream";
/// <summary>
/// Initializes a new instance of the <see cref="SubmissionClient" /> class.
/// </summary>
/// <param name="accessToken">
/// The access token. This is JWT a token obtained from Microsoft Entra ID Directory allowing the caller to invoke the API
/// on behalf of a user
/// </param>
/// <param name="serviceUrl">The service URL.</param>
public SubmissionClient(string accessToken, string serviceUrl)
{
if (string.IsNullOrEmpty(accessToken))
{
throw new ArgumentNullException("accessToken");
}
if (string.IsNullOrEmpty(serviceUrl))
{
throw new ArgumentNullException("serviceUrl");
}
this.accessToken = accessToken;
this.httpClient = new HttpClient
{
BaseAddress = new Uri(serviceUrl)
};
this.imageUploadClient = new HttpClient();
this.DefaultHeaders = new Dictionary<string, string>();
}
/// <summary>
/// Gets or Sets the default headers.
/// </summary>
public Dictionary<string, string> DefaultHeaders { get; set; }
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting
/// unmanaged resources.
/// </summary>
public void Dispose()
{
if (this.httpClient != null)
{
this.httpClient.Dispose();
this.httpClient = null;
GC.SuppressFinalize(this);
}
}
/// <summary>
/// Gets the authorization token for the provided client id, client secret, and the scope.
/// This token is usually valid for 1 hour, so if your submission takes longer than that to complete,
/// make sure to get a new one periodically.
/// </summary>
/// <param name="tokenEndpoint">Token endpoint to which the request is to be made. Specific to your
/// Microsoft Entra ID Directory app. Example: https://login.microsoftonline.com/d454d300-128e-2d81-334a-27d9b2baf002/oauth2/v2.0/token </param>
/// <param name="clientId">Client Id of your Microsoft Entra ID Directory app. Example" 00001111-aaaa-2222-bbbb-3333cccc4444</param>
/// <param name="clientSecret">Client secret of your Microsoft Entra ID Directory app</param>
/// <param name="scope">Scope. If not provided, default one is used for the production API endpoint.</param>
/// <returns>Autorization token. Prepend it with "Bearer: " and pass it in the request header as the
/// value for "Authorization: " header.</returns>
public static async Task<string> GetClientCredentialAccessToken(
string tokenEndpoint,
string clientId,
string clientSecret,
string scope = null)
{
if (scope == null)
{
scope = "https://api.store.microsoft.com/.default";
}
dynamic result;
using (HttpClient client = new HttpClient())
{
string tokenUrl = tokenEndpoint;
using (
HttpRequestMessage request = new HttpRequestMessage(
HttpMethod.Post,
tokenUrl))
{
string strContent =
string.Format(
"grant_type=client_credentials&client_id={0}&client_secret={1}&scope={2}",
clientId,
clientSecret,
scope);
request.Content = new StringContent(strContent, Encoding.UTF8,
"application/x-www-form-urlencoded");
using (HttpResponseMessage response = await client.SendAsync(request))
{
string responseContent = await response.Content.ReadAsStringAsync();
result = JsonConvert.DeserializeObject(responseContent);
}
}
}
return result.access_token;
}
/// <summary>
/// Invokes the specified HTTP method.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="httpMethod">The HTTP method.</param>
/// <param name="relativeUrl">The relative URL.</param>
/// <param name="requestContent">Content of the request.</param>
/// <returns>instance of the type T</returns>
/// <exception cref="ServiceException"></exception>
public async Task<T> Invoke<T>(HttpMethod httpMethod,
string relativeUrl,
object requestContent)
{
using (var request = new HttpRequestMessage(httpMethod, relativeUrl))
{
this.SetRequest(request, requestContent);
using (HttpResponseMessage response = await this.httpClient.SendAsync(request))
{
T result;
if (this.TryHandleResponse(response, out result))
{
return result;
}
if (response.IsSuccessStatusCode)
{
var resource = JsonConvert.DeserializeObject<T>(await response.Content.ReadAsStringAsync());
return resource;
}
throw new Exception(await response.Content.ReadAsStringAsync());
}
}
}
/// <summary>
/// Uploads a given Image Asset file to Asset Storage
/// </summary>
/// <param name="assetUploadUrl">Asset Storage Url</param>
/// <param name="fileStream">The Stream instance of file to be uploaded</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task UploadAsset(string assetUploadUrl, Stream fileStream)
{
using (var request = new HttpRequestMessage(HttpMethod.Put, assetUploadUrl))
{
request.Headers.Add("x-ms-blob-type", "BlockBlob");
request.Content = new StreamContent(fileStream);
request.Content.Headers.ContentType = new MediaTypeHeaderValue(PngContentType);
using (HttpResponseMessage response = await this.imageUploadClient.SendAsync(request))
{
if (response.IsSuccessStatusCode)
{
return;
}
throw new Exception(await response.Content.ReadAsStringAsync());
}
}
}
/// <summary>
/// Sets the request.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="requestContent">Content of the request.</param>
protected virtual void SetRequest(HttpRequestMessage request, object requestContent)
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", this.accessToken);
foreach (var header in this.DefaultHeaders)
{
request.Headers.Add(header.Key, header.Value);
}
if (requestContent != null)
{
request.Content = new StringContent(JsonConvert.SerializeObject(requestContent),
Encoding.UTF8,
JsonContentType);
}
}
/// <summary>
/// Tries the handle response.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="response">The response.</param>
/// <param name="result">The result.</param>
/// <returns>true if the response was handled</returns>
protected virtual bool TryHandleResponse<T>(HttpResponseMessage response, out T result)
{
result = default(T);
return false;
}
}
}
Node.js 示例:适用于 MSI 或 EXE 应用的 Microsoft Store 提交 API
本文提供了 Node.js 代码示例,用于演示如何使用适用于 MSI 或 EXE 应用程序的 Microsoft Store 提交 API。 你可以查看每个示例,了解有关它所演示的任务的详细信息,也可以将本文中的所有代码示例生成到控制台应用程序。
先决条件 这些示例使用以下库:
- node-fetch v2 [npm install node-fetch@2]
使用 node.js 创建应用提交
以下示例调用本文中的其他示例方法,以演示使用 Microsoft Store 提交 API 的不同方法。 要调整此代码以供自己使用,请执行以下操作:
- 将 SellerId 属性分配给合作伙伴中心帐户的卖家 ID。
- 将 ApplicationId 属性分配给需要管理的应用ID。
- 将 ClientId 和 ClientSecret 属性分配给应用的客户端 ID 和密钥,并将 TokenEndpoint URL 中的 tenantid 字符串替换为应用的租户 ID。 有关详细信息,请参阅如何将 Microsoft Entra ID 应用程序与合作伙伴中心帐户相关联
以下示例使用的类调用了 Microsoft Store 提交 API 中的多个方法以更新应用提交。
const config = require('./Configuration');
const submissionClient = require('./SubmissionClient');
const fs = require('fs');
var client = new submissionClient(config);
/**
* Main entry method to Run the Store Submission API Node.js Sample
*/
async function RunNodeJsSample(){
print('Getting Access Token');
await client.getAccessToken();
print('Getting Current Application Draft Status');
var currentDraftStatus = await client.callStoreAPI(client.productDraftStatusPollingUrlTemplate, 'get');
print(currentDraftStatus);
print('Getting Application Packages');
var currentPackages = await client.callStoreAPI(client.packagesUrlTemplate, 'get');
print(currentPackages);
print('Getting Single Package');
var packageId = currentPackages.responseData.packages[0].packageId;
var packageIdUrl = `${client.packageByIdUrlTemplate}`.replace('{packageId}', packageId);
var singlePackage = await client.callStoreAPI(packageIdUrl, 'get');
print(singlePackage);
print('Updating Entire Package Set');
// Update data in Packages list to have final set of updated Packages
currentPackages.responseData.packages[0].installerParameters = "/s /r new-args";
var packagesUpdateRequest = {
'packages': currentPackages.responseData.packages
};
print(packagesUpdateRequest);
var packagesUpdateResponse = await client.callStoreAPI(client.packagesUrlTemplate, 'put', packagesUpdateRequest);
print(packagesUpdateResponse);
print('Updating Single Package\'s Download Url');
// Update data in the SinglePackage object
singlePackage.responseData.packages[0].installerParameters = "/s /r /t new-args";
var singlePackageUpdateResponse = await client.callStoreAPI(packageIdUrl, 'patch', singlePackage.responseData.packages[0]);
print(singlePackageUpdateResponse);
print('Committing Packages');
var commitPackagesResponse = await client.callStoreAPI(client.packagesCommitUrlTemplate, 'post');
print(commitPackagesResponse);
await poll(async ()=>{
print('Waiting for Upload to finish');
return await client.callStoreAPI(client.productDraftStatusPollingUrlTemplate, 'get');
}, 2);
print('Getting Application Metadata - All Modules');
var appMetadata = await client.callStoreAPI(client.appMetadataUrlTemplate, 'get');
print(appMetadata);
print('Getting Application Metadata - Listings');
var appListingMetadata = await client.callStoreAPI(client.appListingsFetchMetadataUrlTemplate, 'get');
print(appListingMetadata);
print('Updating Listings Metadata - Description');
// Update Required Fields in Listings Metadata Object - Per Language. For eg. AppListingsMetadata.responseData.listings[0]
// Example - Updating Description
appListingMetadata.responseData.listings[0].description = 'New Description Updated By Node.js Sample Code';
var listingsUpdateRequest = {
'listings': appListingMetadata.responseData.listings[0]
};
var listingsMetadataUpdateResponse = await client.callStoreAPI(client.appMetadataUrlTemplate, 'put', listingsUpdateRequest);
print(listingsMetadataUpdateResponse);
print('Getting All Listings Assets');
var listingAssets = await client.callStoreAPI(client.listingAssetsUrlTemplate, 'get');
print(listingAssets);
print('Creating Listing Assets for 1 Screenshot');
var listingAssetCreateRequest = {
'language': listingAssets.responseData.listingAssets[0].language,
'createAssetRequest': {
'Screenshot': 1,
'Logo': 0
}
};
var listingAssetCreateResponse = await client.callStoreAPI(client.listingAssetsCreateUrlTemplate, 'post', listingAssetCreateRequest);
print(listingAssetCreateResponse);
print('Uploading Listing Assets');
const pathToFile = './Image.png';
const stats = fs.statSync(pathToFile);
const fileSize = stats.size;
const fileStream = fs.createReadStream(pathToFile);
await client.uploadAssets(listingAssetCreateResponse.responseData.listingAssets.screenshots[0].primaryAssetUploadUrl, fileStream, fileSize);
print('Committing Listing Assets');
var assetCommitRequest = {
'listingAssets': {
'language': listingAssets.responseData.listingAssets[0].language,
'storeLogos': listingAssets.responseData.listingAssets[0].storeLogos,
'screenshots': [{
'id': listingAssetCreateResponse.responseData.listingAssets.screenshots[0].id,
'assetUrl': listingAssetCreateResponse.responseData.listingAssets.screenshots[0].primaryAssetUploadUrl
}]
}
};
var assetCommitResponse = await client.callStoreAPI(client.listingAssetsCommitUrlTemplate, 'put', assetCommitRequest);
print(assetCommitResponse);
print('Getting Current Application Draft Status before Submission');
currentDraftStatus = await client.callStoreAPI(client.productDraftStatusPollingUrlTemplate, 'get');
print(currentDraftStatus);
if(!currentDraftStatus.responseData.isReady){
throw new Error('Application Current Status is not in Ready Status for All Modules');
}
print('Creating Submission');
var submissionCreationResponse = await client.callStoreAPI(client.createSubmissionUrlTemplate, 'post');
print(submissionCreationResponse);
print('Current Submission Status');
var submissionStatusUrl = `${client.submissionStatusPollingUrlTemplate}`.replace('{submissionId}', submissionCreationResponse.responseData.submissionId);
var submissionStatusResponse = await client.callStoreAPI(submissionStatusUrl, 'get');
print(submissionStatusResponse);
// User can Poll on this API to know if Submission Status is INPROGRESS, PUBLISHED or FAILED.
// This Process involves File Scanning, App Certification and Publishing and can take more than a day.
}
/**
* Utility Method to Poll using a given function and time interval in seconds
* @param {*} func
* @param {*} intervalInSeconds
* @returns
*/
async function poll(func, intervalInSeconds){
var result = await func();
if(result.responseData.isReady){
Promise.resolve(true);
}
else if(result.errors && result.errors.length > 0 && result.errors.find(element => element.code == 'packageuploaderror') != undefined){
throw new Error('Package Upload Failed');
}
else{
await new Promise(resolve => setTimeout(resolve, intervalInSeconds*1000));
return await poll(func, intervalInSeconds);
}
}
/**
* Utility function to Print a Json or normal string
* @param {*} json
*/
function print(json){
if(typeof(json) == 'string'){
console.log(json);
}
else{
console.log(JSON.stringify(json));
}
console.log("\n");
}
/** Run the Node.js Sample Application */
RunNodeJsSample();
ClientConfiguration 帮助程序
示例应用使用 ClientConfiguration 帮助程序类将 Microsoft Entra ID Directory 数据和应用数据传递给使用 Microsoft 应用商店提交 API 的每个示例方法。
/** Configuration Object for Store Submission API */
var config = {
version : "1",
applicationId : "...",
clientId : "...",
clientSecret : "...",
serviceEndpoint : "https://api.store.microsoft.com",
tokenEndpoint : "...",
scope : "https://api.store.microsoft.com/.default",
sellerId : "...",
jsonContentType : "application/json",
pngContentType : "image/png",
binaryStreamContentType : "application/octet-stream"
};
module.exports = config;
使用 node.js 的 IngestionClient 帮助程序
IngestionClient 类提供了帮助程序方法,由本示例应用中的其他方法使用以完成以下任务:
- 获取Microsoft Entra ID 访问令牌,该令牌可用于调用 Microsoft 应用商店提交 API 中的方法。 获取令牌后,可以在 60 分钟的令牌有效期内,使用该令牌调用“Microsoft Store 提交 API”。 该令牌到期后,可以重新生成一个。
- 处理 Microsoft Store 提交 API 的 HTTP 请求。
const fetch = require('node-fetch');
/**
* Submission Client to invoke all available Store Submission API and Asset Upload to Blob Store
*/
class SubmissionClient{
constructor(config){
this.configuration = config;
this.accessToken = "";
this.packagesUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/packages`;
this.packageByIdUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/packages/{packageId}`;
this.packagesCommitUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/packages/commit`;
this.appMetadataUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/metadata`;
this.appListingsFetchMetadataUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/metadata/listings`;
this.listingAssetsUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/listings/assets`;
this.listingAssetsCreateUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/listings/assets/create`;
this.listingAssetsCommitUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/listings/assets/commit`;
this.productDraftStatusPollingUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/status`;
this.createSubmissionUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/submit`;
this.submissionStatusPollingUrlTemplate = `/submission/v${this.configuration.version}/product/${this.configuration.applicationId}/submission/{submissionId}/status`;
}
async getAccessToken(){
var params = new URLSearchParams();
params.append('grant_type','client_credentials');
params.append('client_id',this.configuration.clientId);
params.append('client_secret',this.configuration.clientSecret);
params.append('scope',this.configuration.scope);
var response = await fetch(this.configuration.tokenEndpoint,{
method: "POST",
body: params
});
var data = await response.json();
this.accessToken = data.access_token;
}
async callStoreAPI(url, method, data){
var request = {
method: method,
headers:{
'Authorization': `Bearer ${this.accessToken}`,
'Content-Type': this.configuration.jsonContentType,
'X-Seller-Account-Id': this.configuration.sellerId
},
};
if(data){
request.body = JSON.stringify(data);
}
var response = await fetch(`${this.configuration.serviceEndpoint}${url}`,request);
var jsonResponse = await response.json();
return jsonResponse;
}
async uploadAssets(url, stream, size){
var request = {
method: 'put',
headers:{
'Content-Type': this.configuration.pngContentType,
'x-ms-blob-type': 'BlockBlob',
"Content-length": size
},
body: stream
};
var response = await fetch(`${url}`,request);
if(response.ok){
return response;
}
else{
throw new Error('Uploading of assets failed');
}
}
}
module.exports = SubmissionClient;
更多帮助
如果你对 Microsoft Store 提交 API 有疑问,或在使用此 API 管理提交内容时需要帮助,请使用以下资源:
常见问题解答
可以通过Microsoft Store提交 API 执行哪些操作?
Microsoft应用商店提交 API 使开发人员能够自动执行应用管理任务,包括:
- 创建和提交新的应用更新。
- 上传和管理应用包。
- 更新元数据和应用商店列表。
可以将此 API 集成到持续集成或生成工作流中,从而自动执行例行任务以简化发布过程。