Skip to content

Latest commit

 

History

History
124 lines (83 loc) · 9.63 KB

csharp-code-examples-for-the-windows-store-submission-api.md

File metadata and controls

124 lines (83 loc) · 9.63 KB
ms.assetid description title ms.date ms.topic keywords ms.localizationpriority
FABA802F-9CB2-4894-9848-9BB040F9851F
Use the C# code examples in this section to learn more about using the Microsoft Store submission API.
C# sample - submissions for apps, add-ons, and flights
08/03/2017
article
windows 10, uwp, Microsoft Store submission API, code examples, C#
medium

C# sample: submissions for apps, add-ons, and flights

This article provides C# code examples that demonstrate how to use the Microsoft Store submission API for these tasks:

You can review each example to learn more about the task it demonstrates, or you can build all the code examples in this article into a console application. To build the examples, create a C# console application named DeveloperApiCSharpSample in Visual Studio, copy each example to a separate code file in the project, and build the project.

Prerequisites

These examples use the following libraries:

Main program

The following example implements a command line program that calls the other example methods in this article to demonstrate different ways to use the Microsoft Store submission API. To adapt this program for your own use:

  • Assign the ApplicationId, InAppProductId, and FlightId properties to the ID of the app, add-on, and package flight you want to manage.
  • Assign the ClientId and ClientSecret properties to the client ID and key for your app, and replace the tenantid string in the TokenEndpoint URL with the tenant ID for your app. For more information, see How to associate an Azure AD application with your Partner Center account

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/Program.cs" id="Main":::

ClientConfiguration helper class

The sample app uses the ClientConfiguration helper class to pass Azure Active Directory data and app data to each of the example methods that use the Microsoft Store submission API.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/ClientConfiguration.cs" id="ClientConfiguration":::

Create an app submission

The following example implements a class that uses several methods in the Microsoft Store submission API to update an app submission. The RunAppSubmissionUpdateSample method in the class creates a new submission as a clone of the last published submission, and then it updates and commits the cloned submission to Partner Center. Specifically, the RunAppSubmissionUpdateSample method performs these tasks:

  1. To begin, the method gets data for the specified app.
  2. Next, it deletes the pending submission for the app, if one exists.
  3. It then creates a new submission for the app (the new submission is a copy of the last published submission).
  4. It changes some details for the new submission and upload a new package for the submission to Azure Blob Storage.
  5. Next, it updates and then commits the new submission to Partner Center.
  6. Finally, it periodically checks the status of the new submission until the submission is successfully committed.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/AppSubmissionUpdateSample.cs" id="AppSubmissionUpdateSample":::

Create an add-on submission

The following example implements a class that uses several methods in the Microsoft Store submission API to create a new add-on submission. The RunInAppProductSubmissionCreateSample method in the class performs these tasks:

  1. To begin, the method creates a new add-on.
  2. Next, it creates a new submission for the add-on.
  3. It uploads a ZIP archive that contains icons for the submission to Azure Blob Storage.
  4. Next, it commits the new submission to Partner Center.
  5. Finally, it periodically checks the status of the new submission until the submission is successfully committed.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/InAppProductSubmissionCreateSample.cs" id="InAppProductSubmissionCreateSample":::

Update an add-on submission

The following example implements a class that uses several methods in the Microsoft Store submission API to update an existing add-on submission. The RunInAppProductSubmissionUpdateSample method in the class creates a new submission as a clone of the last published submission, and then it updates and commits the cloned submission to Partner Center. Specifically, the RunInAppProductSubmissionUpdateSample method performs these tasks:

  1. To begin, the method gets data for the specified add-on.
  2. Next, it deletes the pending submission for the add-on, if one exists.
  3. It then creates a new submission for the add-on (the new submission is a copy of the last published submission).
  4. Next, it updates and then commits the new submission to Partner Center.
  5. Finally, it periodically checks the status of the new submission until the submission is successfully committed.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/InAppProductSubmissionUpdateSample.cs" id="InAppProductSubmissionUpdateSample":::

Create a package flight submission

The following example implements a class that uses several methods in the Microsoft Store submission API to update a package flight submission. The RunFlightSubmissionUpdateSample method in the class creates a new submission as a clone of the last published submission, and then it updates and commits the cloned submission to Partner Center. Specifically, the RunFlightSubmissionUpdateSample method performs these tasks:

  1. To begin, the method gets data for the specified package flight.
  2. Next, it deletes the pending submission for the package flight, if one exists.
  3. It then creates a new submission for the package flight (the new submission is a copy of the last published submission).
  4. It uploads a new package for the submission to Azure Blob Storage.
  5. Next, it updates and then commits the new submission to Partner Center.
  6. Finally, it periodically checks the status of the new submission until the submission is successfully committed.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/FlightSubmissionUpdateSample.cs" id="FlightSubmissionUpdateSample":::

IngestionClient helper class

The IngestionClient class provides helper methods that are used by other methods in the sample app to perform the following tasks:

  • Obtain an Azure AD access token that can be used to call methods in the Microsoft Store submission API. After you obtain a token, you have 60 minutes to use this token in calls to the Microsoft Store submission API before the token expires. After the token expires, you can generate a new token.
  • Upload a ZIP archive containing new assets for an app or add-on submission to Azure Blob Storage. For more information about uploading a ZIP archive to Azure Blob Storage for app and add-on submissions, see the relevant instructions in Create an app submission and Create an add-on submission.
  • Process the HTTP requests for the Microsoft Store submission API.

[!div class="tabbedCodeSnippets"] :::code language="csharp" source="~/../snippets-windows/windows-uwp/monetize/StoreServicesExamples_Submission/cs/IngestionClient.cs" id="IngestionClient":::

Related topics