Edit in GitHubLog an issue

Get Attributes

Description#

GetAttributes() is used to fetch experimentation and personalized experiences from Target and extract attribute values.

Method#

Copied to your clipboard
TargetAttributes TargetClient.GetAttributes(TargetDeliveryRequest targetRequest, params string[] mboxes)

Parameters#

NameTypeRequiredDefaultDescription
targetRequestTargetDeliveryRequestNonullThe same target request as used for Get Offers​
mboxNamesparams string[]NonullA parameter array of mbox names

Result#

A TargetAttributes object is returned from TargetClient.GetAttributes() which has the following properties and methods:

Property/MethodReturn TypeDescription
ResponseTargetDeliveryResponseReturns the response object normally returned by Get Offers​
ToDictionaryIReadOnlyDictionaryReturns a dictionary of dictionaries with key value pairs grouped by mbox names
ToMboxDictionary(mboxName)IReadOnlyDictionaryReturns a dictionary with key value pairs for the provided mbox
GetBoolean(mboxName, key, defaultValue)boolReturns the value for a specified mbox name and attribute key
GetString(mboxName, key, defaultValue)stringReturns the value for a specified mbox name and attribute key
GetInteger(mboxName, key, defaultValue)intReturns the value for a specified mbox name and attribute key
GetDouble(mboxName, key, defaultValue)doubleReturns the value for a specified mbox name and attribute key
GetValue(mboxName, key, defaultValue)TReturns the value for a specified mbox name and attribute key

Example#

Copied to your clipboard
1var targetClientConfig = new TargetClientConfig.Builder("acmeClient", "ABCDEF012345677890ABCDEF0@AdobeOrg")
2 .Build();
3
4var targetClient = TargetClient.Create(targetClientConfig);
5
6var mboxRequests = new List<MboxRequest> { new (index: 1, name: "a1-serverside-ab") };
7
8var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
9 .Build();
10
11var offerAttributes = targetClient.GetAttributes(targetDeliveryRequest, "demo-engineering-flags");
12
13//returns just the value of searchProviderId from the mbox offer
14var searchProviderId = offerAttributes.GetString("demo-engineering-flags", "searchProviderId");
15
16//returns a simple Dictionary representing the mbox offer
17var engineeringFlags = offerAttributes.ToMboxDictionary("demo-engineering-flags");
18
19// the value of engineeringFlags looks like this
20// {
21// "cdnHostname": "cdn.cloud.corp.net",
22// "searchProviderId": 143,
23// "hasLegacyAccess": false
24// }
25
26var assetUrl = $"http://{engineeringFlags["cdnHostname"]}/path/to/asset";
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.