adlnet / xAPIWrapper

Wrapper to simplify communication to an LRS
https://adlnet.gov/projects/xapi/
Apache License 2.0
219 stars 114 forks source link

sendActivityProfile function using If-Match and LearningLocker LRS #78

Open iamspeeddevil73 opened 7 years ago

iamspeeddevil73 commented 7 years ago

I have a question about the sendActivityProfile functiion. When passing an object as the profileval the function will always use the POST method.

Unfortunately, when using POST the LearningLocker LRS will ignore the If-Match header and will always store the data sent even if it overwrites an updated profile object. If I modify the code so that it uses PUT, LearningLocker behaves as expected and returns http status 412 - precondtion failed.

Just wondering what the correct behaviour here should be? Is this a fault with the wrapper or the LRS?

And what is the reason POST always being used when profileval is an object but not if profileval is an array? Of the top of my head I would expect POST when creating a new profile and PUT when updating an existing profile, why should the method be dependent on the profile data type?

ljwolford commented 7 years ago

For now, POSTs without the etag headers are allowed and the expected behavior from the LRS is to merge the JSON documents together, and overwrite any existing fields with that of the incoming profile so that sounds like it is working correctly on their end. While using If-Match with PUT, as long as the etag value matches the existing document, it should overwrite it.

I will look into the weird behavior with the wrapper regarding objects/arrays. I'm not sure why the profile data type is having any say in what the method will be.