Xamarin 获取状态代码:400,在服务器上发送Apple收据时请求错误
您好,我在使用xamarin表单的应用程序上应用了AppPurchase,并且我的应用程序正在我的服务器(azure)上发送Google收据 但获取状态码:400,发送苹果收据时出现BadRequest错误 这是我的密码:Xamarin 获取状态代码:400,在服务器上发送Apple收据时请求错误,xamarin,xamarin.ios,in-app-purchase,Xamarin,Xamarin.ios,In App Purchase,您好,我在使用xamarin表单的应用程序上应用了AppPurchase,并且我的应用程序正在我的服务器(azure)上发送Google收据 但获取状态码:400,发送苹果收据时出现BadRequest错误 这是我的密码: public async Task<PurchaseResult> PurchaseAsync(AppleReceipt receipt) { switch (Device.RuntimePlatform)
public async Task<PurchaseResult> PurchaseAsync(AppleReceipt receipt)
{
switch (Device.RuntimePlatform)
{
case Device.iOS:
devicePlatform = "ios";
break;
case Device.Android:
devicePlatform = "android";
break;
}
client.DefaultRequestHeaders.Add("deviceplatform", devicePlatform);
client.DefaultRequestHeaders.Add("serviceid", serviceId);
InitializeApiClientUser(true);
client.BaseAddress = new Uri($"{Constants.ApiUrl}purchaseapple{codePrefix}{Constants.ApiKey}");
var s = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat };
HttpResponseMessage response = await client.PostAsJsonAsync(client.BaseAddress, receipt);
CocoSharpControlUI.DisplayAlert("RESPONSE", response.ToString());
client = new HttpClient();
return JsonConvert.DeserializeObject<PurchaseResult>(await response.Content.ReadAsStringAsync());
}
公共异步任务PurchaseAsync(AppleReceipt接收)
{
交换机(设备运行时平台)
{
case Device.iOS:
devicePlatform=“ios”;
打破
case设备。Android:
devicePlatform=“android”;
打破
}
client.DefaultRequestHeaders.Add(“deviceplatform”,deviceplatform);
client.DefaultRequestHeaders.Add(“serviceid”,serviceid);
初始化IpiclientUser(true);
client.BaseAddress=新Uri($“{Constants.ApiUrl}purchaseapple{codeprifix}{Constants.ApiKey}”);
var s=新JsonSerializerSettings{DateFormatHandling=DateFormatHandling.MicrosoftDateFormat};
HttpResponseMessage response=wait client.postsjsonasync(client.BaseAddress,receive);
显示警报(“响应”,RESPONSE.ToString());
client=新的HttpClient();
返回JsonConvert.DeserializeObject(wait response.Content.ReadAsStringAsync());
}
Apple的/verifyReceipt
端点今天已经关闭,这可能是它的一部分:我这边的验证没有问题,但是问题是将收据发送到我的服务器。