facebook / facebook-java-business-sdk

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

Get AdSet with requestAllFields fails due to 'existing_customer_budget_percentage' field #369

Open osib-c opened 2 years ago

osib-c commented 2 years ago

Which SDK version are you using?

12.0.0

What's the issue?

It is not possible to get AdSet using the requestAllFields parameter, as the operation fails with "Missing Permission" error.

Steps/Sample code to reproduce the issue

new AdSet.APIRequestGet(adSetId, context)
          .requestAllFields()
          .requestFullFunnelExplorationModeField(false)
          .execute();

Observed Results:

When trying to get an AdSet with code provided above, an error is thrown: {"error":{"message":"(#100) Missing Permission","type":"OAuthException","code":100,"fbtrace_id":"A9E8sWIryySi0-9OP0WSqlS"}}.

The error itself doesn't say much, but using the Graph API Explorer we figured that the error is caused by 'existing_customer_budget_percentage' field, which is listed in the FIELDS array of the AdSet$APIRequestGet class.

FB developer support confirmed that the field should not be available publicly and removed it from the documentation: https://developers.facebook.com/support/bugs/437990451177639/

The field was not listet in the FIELDS array in version 11.0.0.

Expected Results:

Expected result is an AdSet object with all the fields populated.

Will this be considered as a bug and removed from future versions?

uwemaurer commented 2 years ago

I got it to work by adding these lines to the request:

                .requestFullFunnelExplorationModeField(false)
                 // gives permission denied
                .requestExistingCustomerBudgetPercentageField(false)
                // can't parse this field (SDK expects array but it is an object)
                .requestTargetingOptimizationTypesField(false)
wodepig commented 1 year ago

version: v17.0.3 Check the wrong field and then exclude it by the following operation.

public class FbAdSet {
// place replace
public static String[] list = adsetField from com.facebook.ads.sdk.AdAccount.APIRequestGetAdSets#FIELDS;
    public static void main(String[] args)throws APIException {
// place replace adAccountId and  context
        AdAccount account = new AdAccount(adAccountId,context);
// it can work
     /*  APINodeList<AdSet> execute = account.getAdSets().requestAllFields()
               .requestFullFunnelExplorationModeField(false)
               .requestReviewFeedbackField(false)
                // gives permission denied
                .requestExistingCustomerBudgetPercentageField(false)
                        .execute();*/
// or do this for to check error field
        AdAccount.APIRequestGetAdSets adSets = account.getAdSets();
        for (String key : list) {
           try {
               adSets = setAd(adSets, key, true);
               APINodeList<AdSet> execute1 = adSets.execute();
              System.out.println();
           }catch (Exception e){
               adSets = setAd(adSets, key, false);
               System.out.println(key + " is error");
           }
            System.out.println();
        }
    }
    public static AdAccount.APIRequestGetAdSets setAd( AdAccount.APIRequestGetAdSets adSet,String key,Boolean bb){
       return adSet.requestField(key,bb);
    }
}

国内外软件开发/自动化脚本可联系我