我正在尝试更新网络服务。检索数据时,数据以JSON形式接收,这很好。但是我无法更新Web服务器。以下是我成功提取数据时的响应。
{personaId: 1744648419, userName: "Test User 1", userAbbr: "TSTU1", Male: 1, Female: 0, vcredits: 18572,…}
accountCreatedPlatformName: "PC"
actives: [{id: 249147533520, timestamp: 1454819773, LocationID: "ID42331", active: true, assetId: 62,…},…]
bidTokens: {}
userAbbr: "TSTU1"
userName: "Test User 1"
vcredits: 18572
currencies: [{name: "VMONEY", funds: 18572, finalFunds: 18572}, {name: "USER_AWARDS", funds: 0, finalFunds: 0},…]
0: {name: "VMONEY", funds: 18572, finalFunds: 18572}
finalFunds: 18572
funds: 18572
name: "VMONEY"
1: {name: "USER_AWARDS", funds: 0, finalFunds: 0}
finalFunds: 0
funds: 0
name: "USER_AWARDS"
2: {name: "USER_TOKEN", funds: 0, finalFunds: 0}
finalFunds: 0
funds: 0
name: "USER_TOKEN"
divisionBusiness: 3
divisionInterstate: 4
Male: 1
established: "1454819773"
feature: {specials: 0}
Female: 0
personaId: 1744648419
personaName: "TestUser1"
purchased: false
reliability: {reliability: 125, daysActive: 44, daysInactive: 42, daysUnfinishedTime: 0}
seasonTicket: false
accountList: {account: [,…], activeAccId: 3}
cards: 6
unassignedItemSize: 0
unopenedAccounts: {preOrderAcc: 0, recoveredAcc: 0}
pointsWon: 32
我只想根据提供的信息更新以下部分中的一个或全部。
vcredits: 18572
currencies: [{name: "VMONEY", funds: 18572, finalFunds: 18572}, {name: "USER_AWARDS", funds: 0, finalFunds: 0},…]
0: {name: "VMONEY", funds: 18572, finalFunds: 18572}
finalFunds: 18572
funds: 18572
name: "VMONEY"
1: {name: "USER_AWARDS", funds: 0, finalFunds: 0}
finalFunds: 0
funds: 0
name: "USER_AWARDS"
2: {name: "USER_TOKEN", funds: 0, finalFunds: 0}
finalFunds: 0
funds: 0
name: "USER_TOKEN"
以下是我用来更新的代码
private CreditsResponse vcredits;
public async Task<CreditsResponse> PerformRequestAsync()
{
vcredits = new CreditsResponse();
List<Currency> vmoney = new List<Currency>();
Currency userCoins = new Currency();
userCoins.Name = "VMONEY";
userCoins.FinalFunds = 20000;
userCoins.Funds = 20000;
vmoney.Add(userCoins);
vcredits.Currencies = vmoney;
vcredits.Credits = 20000;
var vMoneyContent = JsonConvert.SerializeObject(vcredits);
HttpContent content = new StringContent(vMoneyContent, Encoding.UTF8, "application/json");
AddMethodOverrideHeader(HttpMethod.Post);
AddCommonHeaders();
var addvCeditsResponseMessage = await HttpClient
.PostAsync(string.Format(Resources.Home + Resources.Credits), content)
.ConfigureAwait(false);
return await Deserialize<CreditsResponse>(addvCeditsResponseMessage);
}
我一直得到404,不知道为什么。对此的任何帮助都会很棒。
答案 0 :(得分:0)
404表示它没有找到您要求的网址。
当我在API上配置POST但是执行GET或者我错误地键入端点名称时(在客户端或服务器端),我通常会遇到此问题。
您是否验证了API端点和请求方法?