Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure on /api/v1/sessions/21/lrs/activities/state #44

Open
mogadanez opened this issue Sep 5, 2022 · 2 comments
Open

Failure on /api/v1/sessions/21/lrs/activities/state #44

mogadanez opened this issue Sep 5, 2022 · 2 comments

Comments

@mogadanez
Copy link

I did setup catapult with cloud lrs.io

more or less working but I have strange issue in with call to GET /api/v1/sessions/21/lrs/activities/state

Added few console.logs at cts/service/plugins/routes/v1/sessions.js

                            if (req.method === "get" && req.params.resource === "activities/state") {
                                if (req.query.stateId === "LMS.LaunchData") {
                                    console.log(uri)
                                    console.log(rawProxyResponsePayload.toString())

on package initialize I'm getting:

Catapult CTS service running on http://4bebdc12c5c3:3399
http://player:3398/lrs/activities/state?agent=%7B%22name%22%3A%22Johnnie%20Schinner%22%2C%22account%22%3A%7B%22name%22%3A%2269d917f%22%2C%22homePage%22%3A%22urn%3Acatapult-cts%3A8bff369%22%7D%2C%22objectType%22%3A%22Agent%22%7D&activityId=https%3A%2F%2Fw3id.org%2Fxapi%2Fcmi5%2Fcatapult%2Fplayer%2Fcourse%2F3d318298-8ad8-468e-a301-3bdb15c62131%2Fau%2F0&stateId=LMS.LaunchData&registration=f8cadac8-30cb-4064-b5b9-a3a0d142c297
! ��Φ��,x�xD�"�V!�P��mY�X��i ɷ_����7�\>j���l�!�£q��a�>�;�5�1Ta0;~��0rF�����L���<L�
                                                                                  uN/VM��auƝ�/d\C}�!��Wi�������uГ�>m�c��D#\���x�bFZ$q�R(1nm�����K={/f���r^�ugDE\�K/�e׳�^�.�k���@����P�k��
               �����io��o���$�����_q����o��q5
Debug: internal, implementation, error 
    SyntaxError: Unexpected token ! in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/usr/src/app/plugins/routes/v1/sessions.js:505:64)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async exports.Manager.execute (/usr/src/app/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
    at async Object.internals.handler (/usr/src/app/node_modules/@hapi/hapi/lib/handler.js:46:20)
    at async exports.execute (/usr/src/app/node_modules/@hapi/hapi/lib/handler.js:31:20)
    at async Request._lifecycle (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:372:32)
    at async Request._execute (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:280:9)

But strange thing is - if I do copy as CURL and repeat it from postman - it works fine and show:

http://player:3398/lrs/activities/state?agent=%7B%22name%22%3A%22Johnnie%20Schinner%22%2C%22account%22%3A%7B%22name%22%3A%2269d917f%22%2C%22homePage%22%3A%22urn%3Acatapult-cts%3A8bff369%22%7D%2C%22objectType%22%3A%22Agent%22%7D&activityId=https%3A%2F%2Fw3id.org%2Fxapi%2Fcmi5%2Fcatapult%2Fplayer%2Fcourse%2F3d318298-8ad8-468e-a301-3bdb15c62131%2Fau%2F0&stateId=LMS.LaunchData&registration=f8cadac8-30cb-4064-b5b9-a3a0d142c297
{"launchMode":"Normal","masteryScore":1,"moveOn":"CompletedAndPassed","contextTemplate":{"contextActivities":{"grouping":[{"id":"https://github.com/xapijs/cmi5-demo/cmi5-demo"}]},"extensions":{"https://w3id.org/xapi/cmi5/context/extensions/sessionid":"973a1ea5-0dd2-473a-9933-566a811a3ddd"}},"entitlementKey":{},"returnURL":"https://localhost/api/v1/sessions/__sessionId__/return-url"}

@mogadanez
Copy link
Author

hm...
interesting. seems my browser added header Accept-Encoding: gzip, deflate, br and it fail with it.

@ahanley
Copy link

ahanley commented Apr 11, 2024

@mogadanez your ticket helped me as i was banging my head for hours on this as well!! What i ended up doing was adding the code below to the lrs.js file!
delete options.headers["accept-encoding"];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants