Reach estimate query fails if placement type is passed in the body


#1

The placement_type value is a required parameter on the Ads API request to get a reach estimate. In my testing, I’ve found that requests are rejected by the server if this parameter value is passed in the body of the request. A 400 Bad Request is returned. The request is accepted if this parameter is pass as a URL query parameter. This is either a bug in Twitter’s implementation of this request, or else the documentation should be updated to reflect that this parameter must be passed as a URL parameter.


#2

@dodnert this is expected behavior and by design right now.

The only Ads API endpoints that accept parameters in the request body are the PUT and POST batch API endpoints. All other endpoints expect all params to be on the query string. The documentation for every endpoint demonstrates this clearly in the example request provided below the parameters table where we only use the query string.

For example, here’s the request example we provide for reach estimate:

GET https://ads-api.twitter.com/0/accounts/4cury/reach_estimate?user_id=7318222&product_type=PROMOTED_TWEETS&similar_to_followers_of_users=14230524

Most resource URLs feature one or more in-line parameter. Many URLs also take explicitly declared parameters on the query string or, for POST or PUT requests, in the body.

Related Documentation:
https://dev.twitter.com/ads/overview/getting-started

In the next major release of the API we’ll begin supporting more complex JSON request bodies rather than relying on the query string for everything, but for the time being nearly all endpoints are restricted to the query string only.