Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8160271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:10:48+00:00 2026-06-06T18:10:48+00:00

How do I send a POST request to twitter API using Play Framework 2.0

  • 0

How do I send a POST request to twitter API using Play Framework 2.0 (with Scala)? The API I’m trying to call work with both GET and POST, and I’ve successfully called it using GET with this code:

val followersURL = "http://api.twitter.com/1/users/lookup.json?user_id=" + listOfFollowers.mkString(",")            
WS.url(followersURL)
  .sign(OAuthCalculator(Twitter.KEY, tokens))
  .get()
  .map{ response => 
      val screenName: Seq[String] = response.json match {
          case res: JsArray => res.value.map{ value => (value \ "name").toString }
          case _ => Seq("")
      }
  }

Then I tried to call the API using POST like this:

WS.url("http://api.twitter.com/1/users/lookup.json")
  .sign(OAuthCalculator(Twitter.KEY, tokens))
  .post(Map("user_id"->listOfFollowers))
  .map { response => 
      val screenName: Seq[String] = response.json match {
          case res: JsArray => res.value.map{ value => (value \ "name").toString }
          case _ => Seq("")
      }
  }

It didn’t work and I get this exception:

[error] play - Waiting for a promise, but got an error: null
java.lang.NullPointerException: null
        at java.io.Reader.<init>(Unknown Source) ~[na:1.7.0_01]
        at java.io.InputStreamReader.<init>(Unknown Source) ~[na:1.7.0_01]
        at oauth.signpost.OAuth.decodeForm(OAuth.java:157) ~[signpost-core.jar:na]
        at oauth.signpost.AbstractOAuthConsumer.collectBodyParameters(AbstractOAuthConsumer.java:236) ~[signpost-core.jar:na]
        at oauth.signpost.AbstractOAuthConsumer.sign(AbstractOAuthConsumer.java:96) ~[signpost-core.jar:na]
        at play.api.libs.oauth.OAuthCalculator.sign(OAuth.scala:106) ~[play_2.9.1.jar:2.0.1]

Since it says that the exception occurs on the OAuthCalculator, I try to comment out the .sign call, and it didn’t throw any exception, but of course I didn’t get the right result.

Am I doing something wrong? What am I doing wrong, and why? How could I fix the problem?

Thanks before.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:10:51+00:00Added an answer on June 6, 2026 at 6:10 pm

    I have found this to work:

    WS.url("http://api.twitter.com/1/users/lookup.json?user_id="+listOfFollowers)
      .sign(OAuthCalculator(Twitter.KEY, tokens))
      .post("ignored")
      .map { response => 
          val screenName: Seq[String] = response.json match {
              case res: JsArray => res.value.map{ value => (value \ "name").toString }
              case _ => Seq("")
          }
      }
    

    I’ve also made notes to revisit my code with every major upgrade of Play! to check if the above gets fixed, because this is obviously not right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send a post request to Parse: https://parse.com/docs/rest#objects-creating . Can't get it
How to send an http request with either post/get method using javascript as an
Trying to send POST request on click event using jQuery with no luck. Here
I know how to send post/get request using any HTTPClient which are explained here
I'm trying to send a POST request to a web app. I'm using the
I am doing work around HTTPClient to send the POST request and get the
I need to send a POST request using java. The server i am trying
I am trying to send a POST request to a server using AFNetworking, and
I have a program to send POST request to a server. I'm using cURL
I have a problem when trying to send a POST request. The sending method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.