The Get Offer Metrics operation returns all metrics (for example, signup count, usage per day) for the specified offer.

Request

The Get Offer Metrics request may be specified as follows. Replace <offer-name> with your offer name

Method Request URI HTTP Version

GET

https://admin-management.contoso.net/offers/<offer-name>/metrics

HTTP/1.1

URI Parameters

None.

Request Headers

The following table describes request headers.

Request Header Description

Authorization

Specifies the credentials for this request. The value of this header must be set Negotiate <token>.

Request Body

None.

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

The status code is embedded in the response for this operation; if successful, it will be status code 200 (OK).

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Header Description

None

None

Response Body

The format of the response body is as follows:

  Copy Code
[{"Name":"DailySignupCount","PrimaryAggregationType":"Count","Unit":"Count","TimeGrain":"1.00:00:00","StartTime":"2012-09-24T15:57:44.2096641-07:00","EndTime":"2012-10-01T15:57:44.2096641-07:00","Values":[]},{"Name":"TotalSignupCount","PrimaryAggregationType":"Count","Unit":"Count","TimeGrain":"1.00:00:00","StartTime":"2012-09-24T15:57:44.2096641-07:00","EndTime":"2012-10-01T15:57:44.2096641-07:00","Values":[]}]

The following table describes the key elements of the response body:

Element Name

Description

Name

A name for the offer that is unique. Must use numbers and letters only.

PrimaryAggregationType

The primary aggregation type of the metric.

Unit

The unit type of the metric.

TimeGrain

The granularity of the metric.

StartTime

The start time of the metric.

EndTime

The end time of the metric.

Values

The values of the metric (if applicable)

Example

Get offer metrics.

  Copy Code
public void GetOfferMetrics(string adminServiceEndpoint, string offername)
{
	HttpClient httpClient = new HttpClient();
	httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BASIC", Convert.ToBase64String(UnicodeEncoding.Unicode.GetBytes("AdminPortal:" + ”password”)))));

			string subscriptionEndpoint = adminServiceEndpoint + "offers/" + offername + "/metrics?startTime=" + DateTime.UtcNow.AddDays(-20)  + "&endTime=" + DateTime.UtcNow;
			var response = httpClient.GetAsync(subscriptionEndpoint);
			var resultsStr = response.Result.Content.ReadAsStringAsync().Result;
			Console.WriteLine(resultsStr + " are the offer metrics");
}