limer icon indicating copy to clipboard operation
limer copied to clipboard

Error get_session_key()

Open sebastianottmann opened this issue 1 year ago • 17 comments

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

sebastianottmann avatar May 30 '23 11:05 sebastianottmann

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

Jan-E avatar May 30 '23 12:05 Jan-E

Limesurvey 5.3.27 PHP 8.1.2

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

sebastianottmann avatar May 30 '23 12:05 sebastianottmann

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.

Jan-E avatar May 30 '23 12:05 Jan-E

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.

sebastianottmann avatar May 30 '23 13:05 sebastianottmann

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 avatar May 30 '23 13:05 Jan-E

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.

Jan-E avatar May 30 '23 14:05 Jan-E

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.

sebastianottmann avatar May 31 '23 07:05 sebastianottmann

Is the issue resolved now? Then please close it.

Jan-E avatar Jun 13 '23 06:06 Jan-E

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.

sebastianottmann avatar Jun 15 '23 07:06 sebastianottmann

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.

r0bis avatar Jul 31 '23 10:07 r0bis

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.

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

Jan-E avatar Aug 23 '23 09:08 Jan-E

@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.

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.

struckma avatar Nov 21 '23 12:11 struckma

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.

jorgesinval avatar Nov 21 '23 12:11 jorgesinval

@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

Jan-E avatar Nov 21 '23 13:11 Jan-E

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.

jorgesinval avatar Nov 21 '23 13:11 jorgesinval