How to use input from javafx TextField to search for tweets using Twitter4j?

twitter4j
java
api

#1

I am having trouble using the input from a javafx Textfield to search for tweets using Twitter4j. If I hard code the keywords in such as
String keyWords = "Obama";

Then it works fine. However I need to be able to get input from the textField to perform this search. I keep getting an error saying: 406:Returned by the Search API when an invalid format is specified in the request.
This is my code, anyone able to help me here?

FilterQuery fq = new FilterQuery();

String keywords;
keywords = keyWordsTextField.getText();
fq.track(keywords);

twitterStream.addListener(statusListener);
twitterStream.filter(fq);

#2

It looks like your Java code is connecting to the Streaming API, so I’m not sure why you’d get an error from the Search (REST) API in this case. Could there be any extraneous information being pulled in from the getText() call, or is a plain text String?