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

Async Insights - Exception while parsing image_asset field

dellax opened this issue · comments

Which SDK version are you using?

18.0.4

What's the issue?

Exception while parsing image_asset field. Graph api returns object {hash: "", url: "", name: "", id: ""} instead of string (sdk)

Steps/Sample code to reproduce the issue

========Start of API Call========
Post: https://graph.facebook.com/v18.0/act_xxxxxxxxxxxx/insights
Content-Disposition: form-data; name="access_token"


omitted


Content-Disposition: form-data; name="time_range"


{"since":"2024-01-10","until":"2024-01-10"}


Content-Disposition: form-data; name="level"


ad


Content-Disposition: form-data; name="breakdowns"


image_asset


Content-Disposition: form-data; name="limit"


25


Content-Disposition: form-data; name="appsecret_proof"


omitted


Content-Disposition: form-data; name="fields"


account_id,actions,ad_id,ad_name,adset_id,adset_name,campaign_id,campaign_name,spend,unique_actions,account_name,impressions,reach,clicks,unique_clicks


Content-Disposition: form-data; name="filtering"


[{field: 'action_type',operator:'IN', value: ['app_install', 'mobile_app_install', 'omni_tutorial_completion', 'omni_level_achieved', 'omni_spend_credits', 'omni_purchase', 'omni_achievement_unlocked']}]


----------------------------689313569058869891--

Observed Results:

  • IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 597 path $.image_asset
  • field image_asset is object instead of string
  • "image_asset":{"hash":"fe849a1241400bda20f49343871e35cf","url":"https://www.facebook.com/ads/image/?d=AQI9AeCIYzup6CWY5SqPOpa8yUTN5Vgy89wpRtkWQ59XzTcCiaE4SQl3XXpa-_9Hn0nywG9KAE0auQQbZu4537HzGGeBaBea5ZNSOtVkAA8WgvgThIxmnbMb9GimMR6C2lvbSTogNZaz_O8mKlf_gKqq","name":"DA_EN_Static_Experimental_V134AH_Facebook_1080x1080_Static.jpg","id":"6490685440776"}}

Expected Results:

  • correctly parse JSON response

thanks for reporting this issue. image_asset is a breakdown and we will need to find a way to figure out how to assign the return type for the breakdowns.

@stcheng Can you please let us know any possible ETA around the fix?
Noticed not only image_asset but even body_asset also comes as json, however breakdowns like age come as string.
Is there any way we can figure out which breakdowns are string and which are json?
Currently checking with hitting the API manually, would like to verify the same with some documentation and https://developers.facebook.com/docs/marketing-api/insights/breakdowns does not have sample responses for all types of breakdowns.

this has been addressed in our latest release v19.0.1 with the introduction of multiple AdAsset* types support in Java.