REST API return 401 (unauthorized access) error when trying to GET tweet preview


#1

hi there

when can successfully GET ad accounts using REST API, however when we try to GET tweet preview using REST API we get 401 error (unauthorized access).

(we are able to get accounts info using REST API)

GET Call; https://ads-api.twitter.com/4/accounts/18ce53ytszw/tweet/preview?text=hello,twitter

Response;
REST API;
Get call: https://ads-api.twitter.com/4/accounts/18ce53ytszw/tweet/preview?text=hello,twitter
Twitter Error Message: {“errors”:[{“code”:“UNAUTHORIZED_ACCESS”,“message”:“This request is not properly authenticated”}],“request”:{“params”:{}}}
Authorization header: OAuth oauth_consumer_key=“eC02zfI424RelWypdmbe52T5A”,oauth_nonce=“5224699”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“1544187944”,oauth_token=“3408515092-TIAEMnumH5kKx7BNhnoLHUXGtFJC4Gg23DQH8RV”,oauth_version=“1.0”,oauth_signature=“ZuSa3pesc%2F2bQ%2BBrQS9orkXFqno%3D”

also, same GET call works fine once submitted using twurl.

twurl GET call;
twurl -H “https://ads-api.twitter.com” “/4/accounts/18ce53ytszw/tweet/preview?text=hello,twitter” -t

twurl response;
{“data”:[{“platform”:“web”,“preview”:"\u003C!DOCTYPE html\u003E \u003Chtml\u003E \u003Chead\u003E \u003Cmeta charset=“utf-8” /\u003E \u003Clink href=“https://ton.twimg.com/macaw-campaigns/css/tweet_preview.bundle.1afb0cd71ee8f4d4d1f5.css” rel=“stylesheet” /\u003E \u003C/head\u003E \u003Cbody\u003E \u003Cdiv class=“Tweet–timeline Tweet Tweet–web " data-tweet-id=“1”\u003E \u003Cimg class=“Tweet-avatar” src=“https://pbs.twimg.com/profile_images/640884649258954756/mK-EOjkG_normal.png” width=“48” height=“48” alt=”"/\u003E \u003Cdiv class=“Tweet-body”\u003E \u003Cdiv class=“Tweet-header”\u003E \u003Cdiv class=“Tweet-userData”\u003E \u003Ca href=“https://twitter.com/yaamur_ads” target="_blank" class=“Tweet-userLink”\u003E \u003Cspan class=“Tweet-name”\u003Eyaamur\u003C/span\u003E \u003Cspan class=“Tweet-screenName”\u003E@yaamur_ads\u003C/span\u003E \u003C/a\u003E \u003C/div\u003E \u003C/div\u003E \u003Cdiv class=“Tweet-text " dir=”"\u003Esay,hello\u003C/div\u003E \u003C/div\u003E \u003Cdiv class=“Tweet-footer”\u003E \u003Cdiv class="Tweet-actions "\u003E \u003Cbutton class=“Tweet-action Tweet-action–reply” type=“button”\u003E \u003Cspan class=“Icon Icon–reply”\u003E\u003C/span\u003E \u003Cspan class=“Tweet-actionCount”\u003E##\u003C/span\u003E \u003C/button\u003E \u003Cbutton class=“Tweet-action Tweet-action–retweet” type=“button”\u003E \u003Cspan class=“Icon Icon–retweet”\u003E\u003C/span\u003E \u003Cspan class=“Tweet-actionCount”\u003E##\u003C/span\u003E \u003C/button\u003E \u003Cbutton class=“Tweet-action Tweet-action–favorite Tweet-action–like” type=“button”\u003E \u003Cspan class=“Icon Icon–heart”\u003E\u003C/span\u003E \u003Cspan class=“Tweet-actionCount”\u003E##\u003C/span\u003E \u003C/button\u003E \u003Cbutton class=“Tweet-action Tweet-action–dm” type=“button”\u003E \u003Cspan class=“Icon Icon–dm”\u003E\u003C/span\u003E \u003C/button\u003E \u003C/div\u003E \u003Cdiv class=“Tweet-context Tweet-context–promotion”\u003E \u003Cdiv class=“Tweet-badge Tweet-badge–promotedBy”\u003E \u003Cspan class=“Icon Icon–promoted”\u003E\u003C/span\u003E \u003Cspan class=“Tweet-badgeText”\u003EPromoted\u003C/span\u003E \u003C/div\u003E \u003C/div\u003E \u003C/div\u003E \u003C/div\u003E \u003C/body\u003E \u003C/html\u003E "}, …],“request”:{“params”:{“text”:“say,hello”,“account_id”:“18ce54s7lzq”}}}


#2

Please see the following posts.