I`m trying to retrieve emails by name using .NET API client but when the email have brackets in name the api doesnt find the object.
This is my code:
string requestID;
// Filter by TaskResultID (the unique id for the import)
SimpleFilterPart sfp = new SimpleFilterPart();
sfp.Property = "Name";
sfp.SimpleOperator = SimpleOperators.equals;
sfp.Value = new string[] { "wednesday - 20140319 - Clients [nws]" };
// Create the RetrieveRequest
RetrieveRequest request = new RetrieveRequest();
request.ObjectType = "Email";
request.Filter = sfp;
request.Properties = new string[] { "ObjectID", "CustomerKey", "Name" };
// Execute the RetrieveRequest
APIObject[] results;
string status = ETclient.Retrieve(request, out requestID, out results);
return results[0] as Email; (ERROR HERE!)
Does anyone can help me?
Thanks a lot.
Attribution to: leribeiro
Possible Suggestion/Solution #1
Simplest way is probably to do String.replace(find, replace) for each bracket. This problem is likely due to the way regex handles square brackets.
Attribution to: DavidSchach
Possible Suggestion/Solution #2
I think the original assumption of the bracket causing issues in the REGEX is the case here. Try escaping the string literals like this:
sfp.Value = new string[] { "wednesday - 20140319 - Clients \U007Bnws\U007D" };
Based on what I am reading, this seems like it's a possible issue.
Attribution to: Kelly J Andrews
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30501