POST /1/batch/account/:account_id/targeting_criteria getting "Unsupported Media Type" in response


#1

Hi,

I was trying to upgrade to use POST /1/batch/account/:account_id/targeting_criteria endpoint and I am getting an “Unsupported Media Type” 415 response. Am I missing anything?

Below is a twurl example:
<=== [2016-05-10 17:50:45 +0000 :: ovq1miwtw :: f8o4 :: 1851862034] twurl -H ads-api.twitter.com -X POST -d “operation_type=Create&params=[{“account_id”:“18ce53uuf0f”,“line_item_id”:“54wq8”,“targeting_type”:“PLATFORM”,“targeting_value”:“1”,“tailored_audience_expansion”:null,“tailored_audience_type”:null},{“account_id”:“18ce53uuf0f”,“line_item_id”:“54wq8”,“targeting_type”:“TAILORED_AUDIENCE”,“targeting_value”:“18wy”,“tailored_audience_expansion”:null,“tailored_audience_type”:null}]” “/1/batch/accounts/18ce53uuf0f/targeting_criteria”
===> [2016-05-10 17:50:46 +0000 :: ovq1miwtw :: f8o4 :: 415 Unsupported Media Type :: 0.508s :: 0/0 (…-1462902646s)]

Thanks!


#2

The “Content-Type” header should be set to “application/json” for batch endpoints. In twurl, this can be done with the -A “Content-Type: application/json” flag. Taking that into account, your sample request should look like the below:

twurl -H ads-api.twitter.com -X POST -A “Content-Type: application/json” -d “operation_type=Create&params=[{“account_id”:“18ce53uuf0f”,“line_item_id”:“54wq8”,“targeting_type”:“PLATFORM”,“targeting_value”:“1”,“tailored_audience_expansion”:null,“tailored_audience_type”:null},{“account_id”:“18ce53uuf0f”,“line_item_id”:“54wq8”,“targeting_type”:“TAILORED_AUDIENCE”,“targeting_value”:“18wy”,“tailored_audience_expansion”:null,“tailored_audience_type”:null}]” “/1/batch/accounts/18ce53uuf0f/targeting_criteria”

Let us know if this works better for you.