Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Client Java for testing the API

Client Java for testing the API 1 year 3 months ago #97456

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
Try this: pastebin.com/GsmWbTgy and take it from there

(btw i am no java programmer, but this got me a json response)
---
Menno Dekker
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97457

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
Actually this line:
post.setEntity( new StringEntity("{\"method\": \"get_session_key\", \"params\": [\"admin\",\"password\"], \"id\": 99}"));

should be able to give you a valid response
---
Menno Dekker
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97459

  • nicola_86
  • nicola_86's Avatar
thanks mdekker. Now I have finally a response.
{"id":99,"result":null,"error":null}

I was wondering what is "id". Anyway I use the username and password to do the login at the administration panel of limesurvey, but the result is null, what does it mean?
Thanks in advance.
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97466

  • nicola_86
  • nicola_86's Avatar
sorry the error was like that: {"id":1,"result":{"status":"Invalid user name or password"},"error":null}

I've also tried with the demo version that you have with username:admin and password:test
and the message is the same. Any suggestion?
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97481

  • nicola_86
  • nicola_86's Avatar
Ok I've solved the problem.
The problem was also in the json string. The correct one is:
post.setEntity( new StringEntity("{\"method\": \"get_session_key\", \"params\": {\"admin\",\"password\"}, \"id\": 99}"));

Here a client to test the key session and a random function of the api, using gson for decoding the message(it's not very optimized, I'm still working on it, but it could be a good start for anyone else that will struggle with java like me)
pastebin.com/7jeGB6vA
Last Edit: 1 year 3 months ago by nicola_86. Reason: the message wasn't written well..sorry
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97489

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
Could you please add your example to our documentation wiki?

Somewhere at the end just like the ruby and php examples.
manual.limesurvey.org/RemoteControl_2_API#Ruby_Example

Posts like this on the forum tend to get lost over time.
---
Menno Dekker
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97491

  • nicola_86
  • nicola_86's Avatar
Could you tell me how I can modify the wiki?
I'd like to do that :)
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97495

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
Using this link:
manual.limesurvey.org/index.php?title=Re...tion=edit§ion=54

You should be able to edit the relevant section in the wiki. User accounts on wiki and forum are the same.
---
Menno Dekker
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97517

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
Starting Help page for the wiki : manual.limesurvey.org/Help:Contents ;)
The administrator has disabled public write access.

Client Java for testing the API 1 year 3 months ago #97578

  • nicola_86
  • nicola_86's Avatar
Done :) thanks for the support guys.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.108 seconds
Donation Image