1

I'm working on an iOS project and want to send statements to an LRS using Tin Can.

For starters I've been using the SCORM public LRS. I've been playing around with the example code on github.com/RusticiSoftware/TinCanObjC/ and have been able to retrieve statements from the public LRS with the getStatementWithId method, but when trying to send statements(using the example code provided on github) I have been repeatedly getting a HTTP 400 response code with the following error message:

"PUT request had statementId parameter conflicting one specified in the statement"

Can anyone provide any insight as to where I'm going wrong? I'm pretty sure that my JSON is of the valid form and I've been unable to find much information about the statementID parameter for PUT requests. Thanks in advance.

Sam.G
  • 11
  • 1
  • 1

1 Answers1

0

It could be an error in your code or a bug in the library but what the error message means is that the request being sent includes a statement with an id property that does not match the statementId header parameter.

Are you copying and pasting exactly this example?

If so, are you using the latest version of the code including this change 6 months ago? What happens if you try the code before that change?

If you are using the example and the latest code, I suggest raising an issue.

The Objective C library doesn't get as much attention as the other libraries, so as a general rule, it may be worth looking at one of them as a reference to contribute to the Objective C library if you need to.

Andrew Downes
  • 1,068
  • 8
  • 20
  • 1
    Hi Andrew, thank you for the response. I've been using the example you linked and I've also tried a few variations on the examples in the Tests folder so I have a feeling that it's a bug. For example, that example omits the required 'withAccount' parameter when declaring a TCAgent. Thank you for your suggestion of trying the previous version of the code. I'll try that and try to figure out whether it's an issue on my end, or a bug, in which case I'll raise an issue on github. – Sam.G Apr 15 '15 at 11:19
  • The issue is still persisting using older commits of the library. Any advice on where the statementID header parameter is being created or how I can access it? I can see the attribute statementToSend.statementID but I'm not sure exactly what it is being mismatched against. – Sam.G Apr 15 '15 at 12:57
  • It looks to me like line 68 (https://github.com/RusticiSoftware/TinCanObjC/blob/master/RSTCAPI/TCLRS.m#L68) is supposed to take the id from the statement and add it as a query-string parameter, which is the correct thing to do. Try and do some debugging to confirm that line is actually doing that. – Andrew Downes Apr 16 '15 at 09:51
  • 1
    Yeah I had checked that previously and it was passing the correct StatementID so I was really stumped. I've solved the error and gotten my code to send statements by removing the statementID parameter from the json statement entirely and setting the urlRequest endpoint with: NSURL *url = [NSURL URLWithString: @"https://cloud.scorm.com/ScormEngineInterface/TCAPI/public/statements"]; NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL: url]; I'm still unsure what was actually causing the error, I've just managed to get around it by letting the LRS generate the ID. – Sam.G Apr 16 '15 at 11:55
  • Glad you found a solution, though it's not ideal. A better solution would be to use POST to send an array (1 item is ok) of statements and then you don't need the ID. POST will be encouraged instead of PUT in future versions of the specification anyway. – Andrew Downes Apr 17 '15 at 10:26