最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Google Play Developer API in C# - Stack Overflow

programmeradmin1浏览0评论

I want to change the price of a subscription in Google Play Console. I retrieve the subscription, it comes in, I see it, change its price, and try to send it back. I wrote the following code and get these errors.

I tried creating a new Subscription without any extra parameters – it didn’t help. I tried removing some parameters like UpdateMask or RegionsVersionVersion – I get errors saying they are required. Even if I try to send it without any changes, I still get an error.

What am I doing wrong?

{"The service androidpublisher has thrown an exception. HttpStatusCode is BadRequest. Request contains an invalid argument."}
{Google.Apis.Requests.RequestError
Request contains an invalid argument. [400]
Errors [
    Message[Request contains an invalid argument.] Location[ - ] Reason[badRequest] Domain[global]
]
}
var getRequest = service.Monetization.Subscriptions.Get(packageName, subscriptionId);
Subscription subscription = await getRequest.ExecuteAsync();

for (int j = 0; j < subscription.BasePlans[0].RegionalConfigs.Count; j++)
{
    string regioncode = subscription.BasePlans[0].RegionalConfigs[j].RegionCode;
    int trueindex = countrycode.IndexOf(regioncode);
    if (trueindex != -1)
    {
        decimal priceValue = decimal.Parse(price[trueindex], CultureInfo.InvariantCulture);
        decimal unitsDecimal = Math.Truncate(priceValue);
        long units = (long)unitsDecimal;
        decimal fractionalPart = priceValue - unitsDecimal;
        int nanos = (int)(fractionalPart * 1_000_000_000M);

        subscription.BasePlans[0].RegionalConfigs[j].Price.Units = units;
        subscription.BasePlans[0].RegionalConfigs[j].Price.Nanos = nanos;
    }
}

var request = service.Monetization.Subscriptions.Patch(subscription, packageName, subscriptionId);
request.UpdateMask = "basePlans.regionalConfigs.price";
request.RegionsVersionVersion = "2022/02";
await request.ExecuteAsync();
发布评论

评论列表(0)

  1. 暂无评论