public async Task <string> PostItemAsync(IRequestItem item) { HttpContent content = new StringContent(JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"); HttpResponseMessage message = await client.PostAsync(GetUri() + item.GetTableName(), content); string primaryKey = null; if (message.IsSuccessStatusCode) { string data = await message.Content.ReadAsStringAsync(); primaryKey = JsonConvert.DeserializeObject <string>(data); } return(primaryKey); }
public async Task <string> PostItemAsync(IRequestItem item, string route) { HttpContent content = new StringContent(JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"); HttpResponseMessage message = await client.PostAsync(GetUri() + item.GetTableName() + "/" + route, content); string primaryKey = null; if (!message.IsSuccessStatusCode) { HttpStatusCode statusCode = message.StatusCode; throw new BadHttpStatusCodeException($"Bad status code: {statusCode}", message); } string data = await message.Content.ReadAsStringAsync(); primaryKey = JsonConvert.DeserializeObject <string>(data); return(primaryKey); }
public async void PutItemAsync(IRequestItem item) { HttpContent content = new StringContent(JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"); HttpResponseMessage message = await client.PostAsync(GetUri() + item.GetTableName() + "/" + "{item.Id}", content); }