Moodle Mobile App - Invalid json in request: No error

Re: Moodle Mobile App - Invalid json in request: No error

by Thomas College -
Number of replies: 12

We think that the 'A required parameter (username) was missing' is caused by our certificate, and not the original error.

In reply to Thomas College

Re: Moodle Mobile App - Invalid json in request: No error

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi everyone,

We recently discovered a bug that can cause this error:

https://tracker.moodle.org/browse/MDL-59741

You can try to manually apply the fix of that issue to see if it fixes the problem for you.

If that doesn't fix it, please check the FAQ to see if you can find the solution in there:

https://docs.moodle.org/33/en/Moodle_Mobile_FAQ

If the issue still persists, please send us your Moodle URL and a test account to mobile@moodle.com so we can take a look. Please reference this post in the mail.

Kind regards,

Dani

In reply to Dani Palou

Re: Moodle Mobile App - Invalid json in request: No error

by Thomas College -

Hi Dani, 

Thanks for the update.  I think we'll wait until Moodle 3.3.2 is released to fix our the invalid JSON error we receive.

We also receive an error stating 'A required parameter (username) was missing'.  The FAQ states that this is due to HTTP redirects.  There was another forum thread here specifically stating that their site was redirecting HTTPS requests to HTTP.  We have HTTPS enabled on our site, and redirect HTTP requests to HTTPS.  It seems that when we connect to our site via the mobile app, the app is trying to connect with HTTP. 

Is there a reason why the app would try to connect via HTTP?  Is there a setting on our site that we could change to make it connect via HTTPS?

Thanks


In reply to Thomas College

Re: Moodle Mobile App - Invalid json in request: No error

by Dave Perry -
Picture of Testers

One question - are you using network passwords e.g. LDAP to login to your moodle? If so, you should have put HTTPS on as soon as you started using these passwords with moodle.

It's also best practice now to secure any site which has even loosely personal information on it.

See this link for what to do:

https://docs.moodle.org/33/en/Transitioning_to_HTTPS

In reply to Dave Perry

Re: Moodle Mobile App - Invalid json in request: No error

by Thomas College -

Hi Dave, 

Yes, the majority of our users use LDAP, but some use Office 365 authentication.  HTTPS is enabled and we have the 'Use HTTPS for logins' enabled under Site Administration > Security > HTTP Security.  Any login done through a desktop browser is done through HTTPS.

The problem seems to be that the Mobile app is trying to use HTTP, not HTTPS.  Is there a setting we need to change to force the app to use HTTPS?

Also, when we change the Mobile authentication type to either 'Via Browser' or 'Via embedded browser' the sign in prompt still appears in app.  Are there additional changes that we need to make to force users to sign in with a browser, and not the app?

Thanks 



Attachment IMG_0005.PNG
In reply to Dave Perry

Re: Moodle Mobile App - Invalid json in request: No error

by Thomas College -

I'm not sure if it is helpful or not, but here is the error we receive in out PHP logs:

[21-Aug-2017 15:45:12 America/New_York] Default exception handler: A required parameter (username) was missing Debug:
Error code: missingparam
* line 503 of \lib\setuplib.php: moodle_exception thrown
* line 567 of \lib\moodlelib.php: call to print_error()
* line 34 of \login\token.php: call to required_param()

Thanks

In reply to Thomas College

Re: Moodle Mobile App - Invalid json in request: No error

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

IMO you should wait to fix the JSON error before checking the other one.

The app performs some fallbacks if a login request fails, and these fallbacks can throw missleading errors if the first call shouldn't have failed. The app always tries to use https first, and if it fails then it retries with http, that's probably why you're seeing http requests in your log.

Also, in order to determine if a site exists (when the user enters the URL), the app calls the login/token.php script without any param, so maybe that request is the one showing in your logs.

Kind regards,

Dani

Average of ratings: Useful (1)
In reply to Dani Palou

Re: Moodle Mobile App - Invalid json in request: No error

by Thomas College -

Hi Dani, 

Thank you for the advice.  After manually applying the JSON error fix the app is working properly for us.  

Again, thank you for all the advice and help.


In reply to Thomas College

Re: Moodle Mobile App - Invalid json in request: No error

by Ali Hastie -

We upgraded to Moodle 3.3.2 and the app works accordingly for us now.

In reply to Ali Hastie

Re: Moodle Mobile App - Invalid json in request: No error

by Gary Lee -

Hi everyone, strangely for us, even after upgrading to 3.3.2 the problem isn't fixed, we are seeing "invalid json in request: Syntax error" in the app

We're running Moodle 3.3.2 on PHP 7.0.22 with LDAP authentication and full HTTPS HSTS (could this be a problem?) I have tried prefixing the URL with https:// in the app but that didn't make a difference.


In the PHP error log we are seeing the following recorded:


2017/09/26 08:36:34 [error] 1330#1330: *1177072 FastCGI sent in stderr: "PHP message: Default exception handler: A required parameter (username) was missing Debug: 

Error code: missingparam

* line 503 of /lib/setuplib.php: moodle_exception thrown

* line 568 of /lib/moodlelib.php: call to print_error()

* line 34 of /login/token.php: call to required_param()" while reading response header from upstream, client: 123.123.123.123, server: moodle.domain.uk, request: "POST /login/token.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "moodle.domain.uk"

2017/09/26 08:36:34 [error] 1330#1330: *1177072 FastCGI sent in stderr: "PHP message: Default exception handler: Exception - Call to a member function out() on string Debug: 

Error code: generalexceptionmessage

* line 156 of /admin/tool/mobile/classes/api.php: Error thrown

* line 119 of /admin/tool/mobile/classes/external.php: call to tool_mobile\api::get_public_config()

* line 228 of /lib/externallib.php: call to tool_mobile\external::get_public_config()

* line 59 of /lib/ajax/service.php: call to external_api::call_external_function()" while reading response header from upstream, client: 123.123.123.123, server: moodle.domain.uk, request: "POST /lib/ajax/service.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "moodle.domain.uk"

2017/09/26 08:36:34 [error] 1330#1330: *1177072 FastCGI sent in stderr: "PHP message: Default exception handler: A required parameter (username) was missing Debug: 

Error code: missingparam

* line 503 of /lib/setuplib.php: moodle_exception thrown

* line 568 of /lib/moodlelib.php: call to print_error()

* line 34 of /login/token.php: call to required_param()" while reading response header from upstream, client: 123.123.123.123, server: moodle.domain.uk, request: "GET /login/token.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "moodle.domain.uk"

2017/09/26 08:36:34 [error] 1330#1330: *1177072 FastCGI sent in stderr: "PHP message: Default exception handler: Coding error detected, it must be fixed by a programmer: Invalid json in request: Syntax error Debug: 

Error code: codingerror

* line 42 of /lib/ajax/service.php: coding_exception thrown" while reading response header from upstream, client: 123.123.123.123, server: moodle.domain.uk, request: "GET /lib/ajax/service.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "moodle.domain.uk"


In reply to Gary Lee

Re: Moodle Mobile App - Invalid json in request: No error

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Gary,

can you send us the Moodle URL? If you don't want to make it public you can send it to mobile@moodle.com.

Kind regards,

Dani

In reply to Dani Palou

Re: Moodle Mobile App - Invalid json in request: No error

by Gary Lee -
Hi,

Yes, no problem I will send it via email now. 


Thank you