Get Attributes (.NET)

Description

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

Method

getAttributes

TargetAttributes TargetClient.GetAttributes(TargetDeliveryRequest targetRequest, params string[] mboxes)

Parameters

Name
Type
Required
Default
Description
targetRequest
TargetDeliveryRequest
No
null
The same Target request as used for Get Offers​
mboxNames
params string[]
No
null
A parameter array of mbox names

Result

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

Property/Method
Return Type
Description
Response
TargetDeliveryResponse
Returns the response object normally returned by Get Offers
ToDictionary
IReadOnlyDictionary
Returns a dictionary of dictionaries with key value pairs grouped by mbox names
ToMboxDictionary(mboxName)
IReadOnlyDictionary
Returns a dictionary with key value pairs for the provided mbox
GetBoolean(mboxName, key, defaultValue)
bool
Returns the value for a specified mbox name and attribute key
GetString(mboxName, key, defaultValue)
string
Returns the value for a specified mbox name and attribute key
GetInteger(mboxName, key, defaultValue)
int
Returns the value for a specified mbox name and attribute key
GetDouble(mboxName, key, defaultValue)
double
Returns the value for a specified mbox name and attribute key
GetValue(mboxName, key, defaultValue)
T
Returns the value for a specified mbox name and attribute key

Example

.NET

var targetClientConfig = new TargetClientConfig.Builder("acmeClient", "ABCDEF012345677890ABCDEF0@AdobeOrg")
    .Build();

var targetClient = TargetClient.Create(targetClientConfig);

var mboxRequests = new List<MboxRequest> { new (index: 1, name: "a1-serverside-ab") };

var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
    .Build();

var offerAttributes = targetClient.GetAttributes(targetDeliveryRequest, "demo-engineering-flags");

//returns just the value of searchProviderId from the mbox offer
var searchProviderId = offerAttributes.GetString("demo-engineering-flags", "searchProviderId");

//returns a simple Dictionary representing the mbox offer
var engineeringFlags = offerAttributes.ToMboxDictionary("demo-engineering-flags");

//  the value of engineeringFlags looks like this
//  {
//      "cdnHostname": "cdn.cloud.corp.net",
//      "searchProviderId": 143,
//      "hasLegacyAccess": false
//  }

var assetUrl = $"http://{engineeringFlags["cdnHostname"]}/path/to/asset";
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3