javaapirestpinterest

Pinterest API: pass multiple values in entity_fields parameter


In using this Pinterest Analytics API:

/ads/v3/reports/async/{advertiser}/delivery_metrics/

I am successful when the entity_fields parameter is a single value like this:

https://api.pinterest.com/ads/v3/reports/async/<advertiserId>/delivery_metrics/?start_date=2021-04-04&end_date=2021-04-05&level=PIN_PROMOTION&entity_fields=AD_GROUP_ID

however I also need the CAMPAIGN_ID, but when I try to include more than one value in the entity_fields parameter I get bad request. I have tried several forms, and all the following fail:

entity_fields=CAMPAIGN_ID&entity_fields=AD_GROUP_ID
entity_fields=CAMPAIGN_ID AD_GROUP_ID
entity_fields="CAMPAIGN_ID AD_GROUP_ID"

Here is an example of the error, although the exact syntax of the error depends on how I tried to parameterize entity_fields:

{"code":1,"data":null,"endpoint_name":"ads_v3_create_advertiser_delivery_metrics_report","error":{"message":"Parameter 'entity_fields' (value CAMPAIGN_ID AD_GROUP_ID) is not one of PRODUCT_GROUP_ID, PIN_PROMOTION_ID, PIN_PROMOTION_NAME, PIN_PROMOTION_STATUS, AD_GROUP_ID, AD_GROUP_NAME, AD_GROUP_STATUS, CAMPAIGN_ID, CAMPAIGN_NAME, CAMPAIGN_STATUS, CAMPAIGN_MANAGED_STATUS. "},"message":"Invalid parameters.","message_detail":"Parameter 'entity_fields' (value CAMPAIGN_ID AD_GROUP_ID) is not one of PRODUCT_GROUP_ID, PIN_PROMOTION_ID, PIN_PROMOTION_NAME, PIN_PROMOTION_STATUS, AD_GROUP_ID, AD_GROUP_NAME, AD_GROUP_STATUS, CAMPAIGN_ID, CAMPAIGN_NAME, CAMPAIGN_STATUS, CAMPAIGN_MANAGED_STATUS. ","status":"failure"}

How does the Pinterest api server expect the entity_fields parameter to be formatted? Thanks in advance for any insight here.


Solution

  • Sorry to answer my own question, but I heard back from pinterest support. To pass multiple field names in the entity_fields parameter, separate by comma:

    https://api.pinterest.com/ads/v3/reports/async/<advertiserId>/delivery_metrics/?start_date=2021-04-04&end_date=2021-04-05&level=PIN_PROMOTION&entity_fields=AD_GROUP_ID,CAMPAIGN_ID