I’m getting the error below when I make a post request to the tailored audience API endpoint (v5) to add users. Any idea what I’m doing wrong?

PMG\TwitterAds\TailoredAudiences\TailoredAudienceRequest Object
(
[method:PMG\TwitterAds\Request:private] => POST
[url:PMG\TwitterAds\Request:private] => accounts/:account_id/tailored_audiences/:id/users
[parameters:PMG\TwitterAds\Request:private] => Array
(
[account_id] => 18ce53uo9ef
[id] => 304zc
[operation_type] => Update
[params] => {“users”:[{“email”:[“a972c10df0a61915fe715741a226d495313104cc7f3d96e1c733bd25e9441d88”]}]}
)

[headers:PMG\TwitterAds\Request:private] => Array
    (
        [Content-Type] => application/json
    )

)
Failed to make request. Client error: POST https://ads-api.twitter.com/5/accounts/18ce53uo9ef/tailored_audiences/304zc/users resulted in a 400 Bad Request response:
{“errors”:[{“code”:“INVALID”,“message”:“The JSON string format is invalid”}],“request”:,“operation_errors”:}
Error: 0 :

@kduncan7

This is likely because your POST body syntax (JSON format) is wrong. Please make sure you’re generating the POST body correctly as shown below (you can’t pass it into query parameter):

Thanks but that’s just the problem. It looks like the post body is correct compared to what’s in the example so I’m at a loss

Could you provide the exact API request/response using twurl along with the formatted POST JSON body?

Thanks!

Thank you I was able to resolve this issue with Shohei Maeda’s response. Thanks again to both of you. I’m all set.

1 Like