Dear Suso Guys,
Would it be possible to have it so that the questionnaires could be downloaded & uploaded from the designer platform?
I would like to archive some of the surveys that I’ve created in our project folders. This is so that in the future people can use and alter the surveys without having their credentials or keeping track of which versions were intermediate and which were final.
This is not that simple as it seems. It is much more expensive than it seems.
We looked at that functionality and it is not on our list for now.
To archive questionnaires, there are two options:
- Download the PDF or HTML version of the questionnaire from Designer
- Download the JSON version of the questionnaire loaded onto Headquarters via this API endpoint:
But, to my knowledge, there is currently no way to create a new questionnaire from these archives.
An additional option: make the final version of the questionnaire public. When folders were added to public questionnaires, there was an idea that institutions might create and populate folders with questionnaires to be shared freely within their organization and with other users. Public questionnaires can be cloned by anyone, and altered/updated as needed.
These solutions may not be exactly what you have in mind, but hopefully give you ideas of reasonable workarounds while waiting for the ideal feature.
Nothing is ever as simple as it seems.
I will download the JSON files as that is pretty close to what I was thinking. I’ve already downloaded the pdf versions. When we’ve finished field testing, we’ll move to put the versions into the public realm.
So I am working on getting the JSON file - my query is https://XXX.mysurvey.solutions/api/v1/questionnaires/6a19c38a-24f6-4574-9403-cafcc2a2b020/1/document"
and the code is
data <- httr::GET(query, authenticate(username, password))
And I get a successful return,
Date: 2018-09-07 12:13
Content-Type: application/json; charset=utf-8
Size: 120 kB
but the content of the JSON (data$content) is:
 22 7b 5c 22 24 74 79 70 65 5c 22 3a 5c 22 51 75 65 73 74 69 6f 6e …
and not strings as I would have expected. Is there something that I’m missing?
I’m fairly confident this is because
httr is showing you the “raw” response of exact bytes sent from the server----the default for non-text responses.
To see the JSON content that you expect, here are two complementary solutions:
- Write the response to disk. Extending your code above:
data <- httr::GET(query, authenticate(username, password), write_disk("C:\my\path\file_name.JSON"))
httr how to parse content of the response:
myQnr <- content(data, type = "application/json; charset=utf-8"). See more here.
I know just enough
httr (and working with REST APIs) to do what I need to do. Others, who either know
httr or REST APIs better, may have better quality answers.