Welcome to the LimeSurvey Community Forum

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

reovery all survey information from json call

  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148041 by cirodev
Hi
I've a survey with equation relevance that estabilishing what question will be displayed.
I want get this information from json call

I use this java code
Code:
import java.io.IOException;
import java.io.UnsupportedEncodingException;
 
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
 
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
 
public class Main {
 
    public static String parse(String jsonLine) {
        JsonElement jelement = new JsonParser().parse(jsonLine);
        JsonObject jobject = jelement.getAsJsonObject();
        String result = jobject.get("result").getAsString();
        return result;
    }
 
 
    public static void main(String[] args) throws UnsupportedEncodingException {
        HttpClient client = HttpClientBuilder.create().build();
 
        HttpPost post = new HttpPost("http://lime.ciro.it/admin/remotecontrol");
        post.setHeader("Content-type", "application/json");
        post.setEntity(new StringEntity("{\"method\": \"get_session_key\", \"params\": [\"admin\", \"password\" ], \"id\": 531612}"));
        try {
            HttpResponse response = client.execute(post);
            if (response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                String sessionKey = parse(EntityUtils.toString(entity));
                post.setEntity(new StringEntity("{\"method\": \"get_survey_properties\", \"params\": [ \"" + sessionKey + "\", 531612 ]}"));
                response = client.execute(post);
                if (response.getStatusLine().getStatusCode() == 200) {
                    entity = response.getEntity();
                    System.out.print(entity); //STRANGE
                    System.out.println(EntityUtils.toString(entity));
                }else{
                    System.out.print(response);
                }
            }
 
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 

This

System.out.print(entity); (second call)


return always empty content. Is there a way to get full survey information comprehend of equation relevance?

thanks

best regards
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148576 by cirodev
Replied by cirodev on topic reovery all survey information from json call
up
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 2 months ago #148580 by LouisGac
Replied by LouisGac on topic reovery all survey information from json call
what is the final goal?
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148581 by cirodev
Replied by cirodev on topic reovery all survey information from json call
Thank you for the reply. I need to have a json with the set of questions and answers but also of the conditions applied to questions that make them visible or not.
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 2 months ago #148582 by LouisGac
Replied by LouisGac on topic reovery all survey information from json call
what for?
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148583 by cirodev
Replied by cirodev on topic reovery all survey information from json call
what changes?
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 2 months ago #148584 by LouisGac
Replied by LouisGac on topic reovery all survey information from json call
different approaches to solve a same problem. It's hard to speak with you...
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148585 by cirodev
Replied by cirodev on topic reovery all survey information from json call
I would like to make a graph of the questionnaire. So do not just questions and answers are necessary but also know any "jumps" between the request and the other. Thank you
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 2 months ago #148586 by LouisGac
Replied by LouisGac on topic reovery all survey information from json call
You could try doing it using the survey structure generated via export: it's in XML
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148587 by cirodev
Replied by cirodev on topic reovery all survey information from json call
It's possibile to make this requeste over ajax?
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 2 months ago #148590 by LouisGac
Replied by LouisGac on topic reovery all survey information from json call
Personally, I'd say I could do it. Just try.
The topic has been locked.
  • cirodev
  • cirodev's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 2 months ago #148594 by cirodev
Replied by cirodev on topic reovery all survey information from json call
ehm in which way?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose