获取桌面应用程序中的错误的堆栈跟踪Get the stack trace for an error in your desktop application

在 Microsoft Store 分析 API 使用此方法,可获取已添加到 Windows 桌面应用程序计划的桌面应用程序的错误堆栈跟踪。Use this method in the Microsoft Store analytics API to get the stack trace for an error in a desktop application that you have added to the Windows Desktop Application program. 此方法只能下载过去 30 天内发生的错误的堆栈跟踪。This method can only download the stack trace for an error that occurred in the last 30 days. 在合作伙伴中心的桌面应用程序的 运行状况报告 中也提供了堆栈跟踪。Stack traces are also available in the Health report for desktop applications in Partner Center.

在可以使用此方法之前,必须首先使用获取桌面应用程序中的错误的详细信息方法来检索与想要检索堆栈跟踪的错误相关联的 CAB 文件 ID 哈希。Before you can use this method, you must first use the get details for an error in your desktop application method to retrieve the ID hash of the CAB file that is associated with the error for which you want to retrieve the stack trace.

必备条件Prerequisites

若要使用此方法,首先需要执行以下操作:To use this method, you need to first do the following:

  • 完成 Microsoft Store 分析 API 的所有先决条件(如果尚未这样做)。If you have not done so already, complete all the prerequisites for the Microsoft Store analytics API.
  • 获取 Azure AD 访问令牌,以供在此方法的请求标头中使用。Obtain an Azure AD access token to use in the request header for this method. 获取访问令牌后,在它到期前,你有 60 分钟的使用时间。After you obtain an access token, you have 60 minutes to use it before it expires. 该令牌到期后,可以获取新的令牌。After the token expires, you can obtain a new one.
  • 获取与要检索堆栈跟踪的错误相关联的 CAB 文件的 ID 哈希。Get the ID hash of the CAB file that is associated with the error for which you want to retrieve the stack trace. 若要获取此值,请使用获取桌面应用程序中的错误的详细信息方法来检索应用中特定错误的详细信息,并使用该方法的响应正文中的 cabIdHash 值。To get this value, use the get details for an error in your desktop application method to retrieve details for a specific error in your app, and use the cabIdHash value in the response body of that method.

请求Request

请求语法Request syntax

方法Method 请求 URIRequest URI
GETGET https://manage.devcenter.microsoft.com/v1.0/my/analytics/desktop/stacktrace

请求头Request header

| 标头Header | 类型Type | 描述Description | |---------------|--------|-----------------------------------------------------------------------------| | 授权Authorization | 字符串string | 必需。Required. Azure AD 访问令牌的格式为 Bearer <token> 。The Azure AD access token in the form Bearer <token>. |  

请求参数Request parameters

参数Parameter 类型Type 描述Description 必需Required
applicationIdapplicationId 字符串string 要为其获取堆栈跟踪的桌面应用程序的产品 ID。The product ID of the desktop application for which you want to get a stack trace. 若要获取桌面应用程序的产品 ID,请在合作伙伴中心 ((例如运行状况报告中打开适用于桌面应用程序的分析报告,) 并从 URL 中检索产品 ID。To get the product ID of a desktop application, open any analytics report for your desktop application in Partner Center (such as the Health report) and retrieve the product ID from the URL. Yes
cabIdHashcabIdHash 字符串string 获取与要检索堆栈跟踪的错误相关联的 CAB 文件的唯一 ID 哈希。The unique ID hash of the CAB file that is associated with the error for which you want to retrieve the stack trace. 要获取此值,请使用获取桌面应用程序中的错误的详细信息方法来检索应用程序中特定错误的详细信息,并使用该方法的响应正文中的 cabIdHash 值。To get this value, use the get details for an error in your desktop application method to retrieve details for a specific error in your application, and use the cabIdHash value in the response body of that method. Yes

 

请求示例Request example

以下示例演示如何使用此方法获取堆栈跟踪。The following example demonstrates how to get a stack trace using this method. applicationIdcabIdHash 值替换为桌面应用程序的相应值。Replace the applicationId and cabIdHash parameters with the appropriate values for your desktop application.

GET https://manage.devcenter.microsoft.com/v1.0/my/analytics/desktop/stacktrace?applicationId=10238467886765136388&cabIdHash=54ffb83a-e159-41d2-8158-f36f306cc01e HTTP/1.1
Authorization: Bearer <your access token>

响应Response

响应正文Response body

Value 类型Type 说明Description
Value arrayarray 一组对象,其中每个包含堆栈跟踪数据的一个帧。An array of objects that each contain one frame of stack trace data. 有关每个对象中的数据的详细信息,请参阅以下堆栈跟踪值部分。For more information about the data in each object, see the stack trace values section below.
@nextLink 字符串string 如果存在其他数据页,则此字符串包含一个你可用来请求下一页数据的 URI。If there are additional pages of data, this string contains a URI that you can use to request the next page of data. 例如,当请求的 top 参数设置为 10,但查询的错误超过 10 行时,就会返回此值。For example, this value is returned if the top parameter of the request is set to 10 but there are more than 10 rows of errors for the query.
TotalCountTotalCount integerinteger 查询的数据结果中的行总数。The total number of rows in the data result for the query.

堆栈跟踪值Stack trace values

Value 数组中的元素包含以下值。Elements in the Value array contain the following values.

Value 类型Type 描述Description
levellevel 字符串string 此元素在调用堆栈中表示的帧编号。The frame number that this element represents in the call stack.
imageimage 字符串string 可执行文件或库映像的名称,包含在此堆栈帧中调用的函数。The name of the executable or library image that contains the function that is called in this stack frame.
函数function 字符串string 在此堆栈帧中调用的函数名称。The name of the function that is called in this stack frame. 仅当应用包含可执行文件或库的符号时才可用。This is available only if your app includes symbols for the executable or library.
offsetoffset 字符串string 相对于函数开始的当前指令的字节偏移量。The byte offset of the current instruction relative to the start of the function.

响应示例Response example

以下示例举例说明此请求的 JSON 响应正文。The following example demonstrates an example JSON response body for this request.

{
  "Value": [
    {
      "level": "0",
      "image": "Contoso.ContosoApp",
      "function": "Contoso.ContosoApp.MainPage.DoWork",
      "offset": "0x25C"
    }
    {
      "level": "1",
      "image": "Contoso.ContosoApp",
      "function": "Contoso.ContosoApp.MainPage.Initialize",
      "offset": "0x26"
    }
    {
      "level": "2",
      "image": "Contoso.ContosoApp",
      "function": "Contoso.ContosoApp.Start",
      "offset": "0x66"
    }
  ],
  "@nextLink": null,
  "TotalCount": 3
}