Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

LSRC2 JSON/RPC export_responses() returns an empty string

  • kawsay
  • kawsay's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 10 months ago #216754 by kawsay
Hi,
I'm trying to export responses through the API using Ruby. I've no problem for getting a session key and the call to the method export_responses returns a 200 OK with an empty string as payload.

After several tests, I can't figure out what's wrong with my instance. Here's what I've tested:
  • Verify that the 'Content-Type' header is set to 'application/json'

The content-type of the HTTP request must be application/json.  Most formatting errors are a failure to set the content-type header. This will result in a null response from the server (not a JSON response).

  • Verify that each parameters are passed in the corresponding order

  The parameter structure uses arrays of values - you *must* send the values in the API expected order (see jsonrpc specification ).

  • Fill 3 or more parameters (3 are required, session_key, survey_id, document_type)
  • Tweak some parameter's value
  • Test different value for the DocumentType parameter:

@param string $sDocumentType any format available by plugins (for example : pdf, csv, xls, doc, json)


Here's the JSON payload I'm sending:
Code:
"{\"method\":\"export_responses\",\"params\":[\"JatBameDZtYllc9jGFCvZnZeUWXUrjVI\",534582,\"json\"]}"
The headers:
Code:
accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
accept: */*
user-agent: Ruby
host: my.instance.org
content-type: application/json
connection: Keep-Alive
content-length: 89
It returns 200OK and the payload is "" (empty string)


My questions is: should I install a plugin in order to export responses through the API ?

Thanks for your time,
Regards

ps: I'd be glad to share my script (once working & clean) to the community, as it lack of a Ruby example
The topic has been locked.
  • kawsay
  • kawsay's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 10 months ago - 2 years 10 months ago #216758 by kawsay
I solved my problem by passing "id": 1 as additional parameter (as in other snippets)
The full payload is
Code:
"{\"method\":\"export_responses\",\"params\":[\"mCazeazeaezIOkJ~K5RC29anh1sq~m\",534582,\"json\"],\"id\":1}"

If you've time,
Why is this parameter needed ? Is it a LimeSurvey requirement, or a JSON/RPC one ? Can't see any reference to it in the documentation
Last edit: 2 years 10 months ago by kawsay. Reason: format
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago - 2 years 10 months ago #216774 by DenisChenu

I solved my problem by passing "id": 1 as additional parameter (as in other snippets)
The full payload is
Code:
"{\"method\":\"export_responses\",\"params\":[\"mCazeazeaezIOkJ~K5RC29anh1sq~m\",534582,\"json\"],\"id\":1}"

If you've time,
Why is this parameter needed ? Is it a LimeSurvey requirement, or a JSON/RPC one ? Can't see any reference to it in the documentation

 
JSON-RPC ! not related to LimeSurvey implementation.

No JSONRPC library for Ruby ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 2 years 10 months ago by DenisChenu. Reason: ? to !
The topic has been locked.
  • kawsay
  • kawsay's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 10 months ago #216814 by kawsay
indeed, I'm so ignorant !

There's some, though I prefer reinventing the wheel using native libraries (already learned something by doing so).

Thanks for you answer
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose