'Add description to a new/existing apk and publish to Google Play
I have the following code to publish apk to Google Play:
public async Task<GooglePlayAPIResult> Publish(Stream apk, string packageName, string title, string description)
{
using (var svc = new AndroidPublisherService(new BaseClientService.Initializer { HttpClientInitializer = _credentials }))
{
AppEdit edit = await svc.Edits.Insert(new AppEdit(), packageName).ExecuteAsync();
var success = await svc.Edits.Apks.Upload(packageName, edit.Id, apk, "application/octet-stream").UploadAsync();
if (success.Exception != null)
throw success.Exception;
var request = await svc.Edits.Listings.Update(new Listing { Title = title, FullDescription = description, ShortDescription = description }, packageName, edit.Id, "en-US").ExecuteAsync();
// check status and throw an exception if it fails
var commit = await svc.Edits.Commit(packageName, edit.Id).ExecuteAsync();
}
return new GooglePlayAPIResult { Success = true };
}
How do I check the status of request and throw an exception if it fails?
Also, here is the code for creating a new app:
private async Task<GooglePlayAPIResult> Create(Stream apk, string title)
{
using (var svc = new PlaycustomappService(new BaseClientService.Initializer { HttpClientInitializer = _credentials }))
{
var created = await svc.Accounts.CustomApps.Create( new CustomApp { Title = title, LanguageCode = "en_US" },
_developerId, apk, "application/octet-stream").UploadAsync();
if (created.Exception != null)
{
return new GooglePlayAPIResult { Success = false, Error = (created.Exception as GoogleApiException).Error.Message };
}
// add description
}
return new GooglePlayAPIResult { Success = true };
}
How do I add description and check it's status?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
