-
Notifications
You must be signed in to change notification settings - Fork 24
Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 - When posting new Statement #32
Comments
The jxapi postStatement method will return a single ID, and it's a string.
The postStatements method will return an ID for each statement in an ArrayList.
|
Hi,
returns a single ID which is a string. But, in the code
So basically both
for statementClient.postStatement(statement), throws an exception. For example, could you tell me what should be a return JSON object from the LRS for a statement:
Based on that I will change the LRS side response code. Note that the statement is successfully stored in the LRS and the Statement ID is returned. The problem is only in the parsing of the JSON response at line: Thanks |
Whenever one or more statements are POSTed, the LRS must return an array of IDs, like you described. So if a single statement is posted, the LRS should return |
Hi, I tried to POSTed a statement to LRS successfully stored the statement and returned the ID. And the jxApi still threw an JsonSyntaxException as mentioned above. So guess its a bug? You can find the following statement at http://adlnet.github.io/xapi-statement-viewer/:
|
This test posts and returns an ID with no exceptions thrown.
It returns The statement stored:
Is there a public link to your LRS for me to test against? |
Originally I had my own local server from compiled from:
But I also tested with the ADL's LRS. The following code also throws an exception:
|
I got the same exception when sending a xAPI statement to a Learning Locker instance. Anyway, the statement is properly saved in the store. |
Guys,
I am trying to use jxapi with OpenLrs- which is an open source LRS written in Java. So when I try to Post a single statement (or multiple statements for that matter), it returns Json response as Jsonarray. For eg:
For a post statement below:
OpenLrs' response is:
Now this throws an error:
Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2
in the class-StatementClient in the function:
public String postStatement(Statement statement)
at line:
JsonArray jsonResult = gson.fromJson(result, JsonArray.class);
I even tried to convert the response to Jsonarray at the source- Openlrs before returning, but it still throws the same error.
Could someone tell me what's the expected response? In the specification, there is no hint given except that it says the POST should return an array of id, which as I see it, the Openlrs does follow suit? Could anyone please help me? Thanks
The text was updated successfully, but these errors were encountered: