Skip to main content

Post to Twitter timeline using REST Assured

To Post a tweet on Twitter timeline follow below steps:

Step 1: Create a twitter account. Add your mobile number if not already added.

Step 2: Create your app on Twitter and generate keys and tokens. Follow steps here.

Step 3: Add following code

public class TwitterAPITest 
	String consumerKey = "s1lAvT5uU3fPLhzgI5m4cFBz8";
	String consumerSecret = "0QU8aC58Ypy0hJQIeqs4Y1PJwjWV2OffdthjJ55JZJvZaGccns";
	String accessToken = "1441253365-gAUOzD1QjLZg7CCKpKJ84j8HRuONiTSGi9r9mZn";
	String tokenSecret = "tM1y94Nx4rD9iQirOIL9xxuUlGOForSLK7xGzlpl4Oy2y";
	public void setup()
		RestAssured.baseURI = "";
		RestAssured.basePath = "/1.1/statuses";

    /*Post request example*/
	public void postExample()
            .oauth(consumerKey, consumerSecret, accessToken, tokenSecret)
            .queryParam("status", "REST Assured Automation Tweet.")

Submitted by tgoswami on September 1, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.