facebook / facebook-java-business-sdk

Java SDK for Meta Marketing APIs

Home Page:https://developers.facebook.com/docs/business-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

age_targeting fields is not working.

PengGoon opened this issue · comments

I need your help.

Which SDK version are you using?

sdk 16.0.0

What's the issue?

Campaign insights API tried to get age_targeting information by adding Breakdowns=age, but the age_targeting value was not returned. Is there a problem with this field?
No errors occur when calling.

Steps/Sample code to reproduce the issue

String[] fields = {"account_id","campaign_id","campaign_name","impressions","spend","clicks","reach","age_targeting"};
List apiFields = new ArrayList<>();
apiFields.addAll(Arrays.asList(fields));
APINodeList insights = account.getInsights().requestFields(apiFields).setBreakdowns("age,gender").execute();

Observed Results:

When calling https://developers.facebook.com/tools/explorer/, the output is shown below.
{
"date_start": "2023-03-08",
"date_stop": "2023-03-08",
"impressions": "2541",
"spend": "4376",
"clicks": "6",
"reach": "1848",
"gender_targeting": "female",
"age": "25-34",
"gender": "female"
},
gender_targeting is normal.
I want the age_targeting value to be returned as well.
To use the insight.getFieldAgeTargeting() command.
The java code returns without an age value.

I would appreciate a reply.

I found getRawResponseAsJsonObject().get("age")).

The Age value could be obtained in this way.