facebook / facebook-java-business-sdk

Java SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
393 stars 324 forks source link

age_targeting fields is not working. #417

Closed PengGoon closed 1 year ago

PengGoon commented 1 year ago

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.

PengGoon commented 1 year ago

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

The Age value could be obtained in this way.