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

API version issue #391

Closed kataku closed 2 years ago

kataku commented 2 years ago

Which SDK version are you using?

com.facebook.business.sdk facebook-java-business-sdk 13.0.0

What's the issue?

All versions of the graph api before version 14 currently give a response http status 400 body of the sort

{"error":{"message":"(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v14.0."...

A fix exists https://github.com/facebook/facebook-java-business-sdk/issues/390

https://github.com/facebook/facebook-java-business-sdk/blob/main/src/main/java/com/facebook/ads/sdk/APIConfig.java

public static final String DEFAULT_API_VERSION = "v13.0"; needs to be public static final String DEFAULT_API_VERSION = "v14.0";

I have downloaded the API code and made this change but when i try to compile it i get a new problem. The API call works but all the classes have an issue with nodelist return types which i assume means i've done something wrong with my compile settings or dependancies? Whilst an upodated SDK on maven would be perfect, a hint on fixing this second issue would get me unblocked.

"The return type is incompatible with APINode.parseResponse(String, APIContext, APIRequest, String)"

Steps/Sample code to reproduce the issue

`package metaConnector;

import java.util.Arrays;

import com.facebook.ads.sdk.APIContext; import com.facebook.ads.sdk.APIException; import com.facebook.ads.sdk.AdAccount; import com.facebook.ads.sdk.AdsInsights;

public class Sandbox { public static void main (String args[]) throws APIException {

String access_token = "xxxx";
String ad_account_id = "xxxx";
String app_secret = "xxxx";
String app_id = "xxxx";
APIContext context = new APIContext(access_token).enableDebug(true);

new AdAccount(ad_account_id, context).getInsights()
  .setTimeRange("{\"since\":\"2022-05-16\",\"until\":\"2022-06-15\"}")      
  .setLevel(AdsInsights.EnumLevel.VALUE_CAMPAIGN)
  .setBreakdowns(Arrays.asList())
  .requestField("impressions")
  .requestField("spend")      
  .requestField("ctr")
  .requestField("unique_ctr")      
  .execute();

} }`

Observed Results:

400 body of the sort

{"error":{"message":"(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v14.0."...

Expected Results:

Ideally a 200 and json data

stcheng commented 2 years ago

it's updated to v14.0. thanks!