private async Task <HttpResponseMessage> SendAsync(HttpMethod method, TelemetryPayload payload) { var request = new HttpRequestMessage(method, "sonarlint") { Content = new StringContent(TelemetryHelper.Serialize(payload), Encoding.UTF8, "application/json") }; return(await this.client.SendAsync(request).ConfigureAwait(false)); }
public async Task <bool> SendPayloadAsync(TelemetryPayload payload) { return(await RetryHelper.RetryOnExceptionAsync(maxRetries, retryTimeout, async() => { var response = await SendAsync(HttpMethod.Post, payload); response.EnsureSuccessStatusCode(); })); }
public async Task <bool> SendPayload(TelemetryPayload payload) { return(await RetryHelper.RetryOnExceptionAsync(3, TimeSpan.FromSeconds(2), async() => { var response = await SendAsync(HttpMethod.Post, payload); response.EnsureSuccessStatusCode(); })); }
public static string Serialize(TelemetryPayload payload) { return(JsonHelper.Serialize(payload)); }