cloudyr / limer

A LimeSurvey R Client
MIT License
67 stars 37 forks source link

Error get_session_key() #63

Open sebastianottmann opened 1 year ago

sebastianottmann commented 1 year ago

Thank you for the limer package. When using get_session_key() I get the following error message:

Error: Argument txt must be a JSON string, URL or file.

I have installed the latest version of the limer package and also already looked at possible solutions to the problem here on github. The script is also run regularly and in mid-May, it was still working without error message.

Are there any other ideas how I can fix the problem?

Thanks Sebastian

Jan-E commented 1 year ago

Which version of Limesurvey are you running? And which version of PHP?

sebastianottmann commented 1 year ago

Limesurvey 5.3.27 PHP 8.1.2

Do you think that with an update to the latest version the problem should be solved?

Jan-E commented 1 year ago

Limer should work fine with LS 5.3. Did you recently update your PHP version? PHP 8.1 had a known problem with limer, which was solved by https://github.com/cloudyr/limer/commit/bc807c61fb834cb0034c376d814e80f126fc796c on April 12. If you did not update limer after that date: do it now.

With what script are you calling get_session_key()? If it is a custom script written in R or PHP, please share the script. The change from ‘admin’ to ‘username’ which was needed for the jsonRPCClient.php of Limesurvey might break custom scripts.

sebastianottmann commented 1 year ago

I have updated limer before publishing the issue. I also just uninstalled the package and reinstalled it again. Unfortunately the problem is still there.

I have to check with my administrator if PHP was updated on the server.

I am using an R script to address the function. In the script the data from Limesurvey should be loaded and then analyzed. At the beginning, I have defined the following (in the original script with content):

options(lime_api = "") options(lime_username = "") options(lime_password = "") limer::get_session_key()

As already written, the script still worked without problems in mid-May.

Jan-E commented 1 year ago

Mmm. We are using for some R-scripts the same calling sequence: https://forums.limesurvey.org/index.php/forum/installation-a-update-issues/127953-remotecontrol-doesn-t-work-after-update-to-php-8-1#231008

But I did not test that yet with a Limesurvey running under PHP 8.1. Will take some time before I can do that.

Jan-E commented 1 year ago

BTW: I would not be surprised if LS 5.3 has problems with PHP 8.1. PHP 8.1 compatibility is on the roadmap for LS 6.0.

https://forums.limesurvey.org/index.php/forum/installation-a-update-issues/133917-is-php-8-1-or-8-2-supported-by-ls-5-x

https://manual.limesurvey.org/LimeSurvey_roadmap#LimeSurvey_5.3

Please check with your administrator when the PHP update was done.

sebastianottmann commented 1 year ago

Thanks for the help and the answer. I clarify with my administrator that the Limesurvey is updated to the current version and would then try the data download with limer again.

Jan-E commented 1 year ago

Is the issue resolved now? Then please close it.

sebastianottmann commented 1 year ago

Unfortunately, the issue persists. We are now trying to update to version 6 of Limesurvey and hope that the problem will then no longer exist. I would then let you know again if this is the case.

r0bis commented 1 year ago

Just to mention - this kind of error can occur also when server returns unexpected response - for example you are hosting LS on one of the typical platforms like a2 etc., and the system decides to check if you are not a bot (captcha). You can check if this is the case opening your LS installation admin URL https://yourLSurl.org/admin and if you see a captcha, accompanied by something like "we need to verify because of some unusual traffic" - then you solve the captcha and re-run script you were using limer in - it worked for me.

statistaBradleyPresentati commented 11 months ago

I also have this problem. LS 6.2.1 with PHP 8.0.28. I've tried using the old params (admin, password) as well as the new (username, password, plugin = 'AuthDB')- no luck. Still runs great on an LS 3.22.28 with PHP 7.2.3, so I'm not sure what's going on.

Jan-E commented 11 months ago

@statistaBradleyPresentati What is the exact command you are using to get the session key? Are you using PHP or R to get it?

statistaBradleyPresentati commented 11 months ago

@statistaBradleyPresentati What is the exact command you are using to get the session key? Are you using PHP or R to get it?

This is what ended up working for me (in R):

body.json <- list(method = "get_session_key", params = list(username = user, password = pw), id = 1)

  r <- POST(url = "example.url", content_type_json(),
          body = jsonlite::toJSON(body.json, auto_unbox = TRUE))

  session_key <- as.character(jsonlite::fromJSON(content(r, encoding="utf-8"))$result)

The id=1 parameter made the difference, at least in my case.

struckma commented 8 months ago

I had to modify the httr::content() call amending the argument as = "text" as proposed by the httr manual to suppress automatic parsing of the JSON response from the server.

jorgesinval commented 8 months ago

I had to modify the httr::content() call amending the argument as = "text" as proposed by the httr manual to suppress automatic parsing of the JSON response from the server.

Thank you. I updated limer to the last version and now it is working properly.

Jan-E commented 8 months ago

@jorgesinval With which Limesurvey version are you working? Standard limer with LS 6.3.5+ is broken. See https://github.com/cloudyr/limer/pull/66

jorgesinval commented 8 months ago

I am using 6.2.5. Thanks for the warning, @Jan-E. I will not update LS to 6.3.5 version for now. Before updating LS to the latest version, I used Python's citric package. It worked but it was a workaround, using reticulate.