5

I'm using the StackWrap4J java wrapper for the Stack Overflow API.
But every code I try, that uses methods of this java wrapper, ends with this JSONException:

net.sf.stackwrap4j.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at net.sf.stackwrap4j.json.JSONTokener.syntaxError(JSONTokener.java:423)
at net.sf.stackwrap4j.json.JSONObject.(JSONObject.java:183)
at net.sf.stackwrap4j.json.JSONObject.(JSONObject.java:310)
at net.sf.stackwrap4j.StackWrapper.getUserById(StackWrapper.java:716)
at stackoverflowmain.main(stackoverflowmain.java:26)
Exception in thread "main" java.lang.NullPointerException
at stackoverflowmain.main(stackoverflowmain.java:32)


This is the current code that resulted with the above exception (but it's same for any method from the this wrapper that I have tried) :

StackOverflow stack = new StackOverflow();
User user = null;
try {
    user = stack.getUserById(4629408);
} catch (JSONException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
int rep = user.getReputation();
System.out.print(rep);
3

The StackWrap4J library is very obsolete. Its page states:

The latest build was tested against version 1.0 of the API on July 28th.

But API version 1 has been shut down for quite a while. The API is currently at version 2.2.

Choose a different library. The list is at stackapps.com/questions/tagged/library+java. Choose one that supports API version 2.0 or greater.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .