Reputation: 461
I'm using Facebook ads api SDK for .net (http://www.nuget.org/packages/Facebook/6.4.2) and when I catch an error, the message is always the same general error in the exception message object:
(FacebookApiException - #100) Invalid parameter
It happens since I moved to the versioned calls (v2.2) - before that I used the unversioned calls and it was fine. For example, this is how I get the error (using regular try catch in c#):
try
{
FacebookClient facebookClient = new FacebookClient();
facebookClient.AccessToken = "<YOUR_ACCESS_TOKEN>"
Dictionary<string, object> parameters = new Dictionary<string, object>();
string name = Guid.NewGuid().ToString();
parameters.Add("name", name);
parameters.Add("conversion_specs", "");
parameters.Add("campaign_id", "6024570447800");
parameters.Add("creative", "{\"creative_id\":\"6024570452200\"}");
parameters.Add("redownload", "false");
parameters.Add("tracking_specs", "");
parameters.Add("view_tags", "[]");
var result = facebookClient.Post("v2.2/act_107893676040337/adgroups", parameters) as IDictionary<string, object>;
}
catch (Exception ex)
{
FacebookApiException fbEx = ex as FacebookApiException;
string errorMsg = fbEx.Message;
}
It happens because Facebook changed the return error object and added 2 new fields: error_user_title, error_user_msg. Is there a way to access these fields in the FacebookApiException object ? How can I extract the relevant error message?
Upvotes: 2
Views: 259
Reputation: 461
I dived into this issue and it's not a Facebook problem. The problem is in the third party SDK.
I contacted the development team, they aware of this issue and fixed it in the last beta version.
Upvotes: 2