Export API not working on new workspace

I am using python API export feature but in the new workspace I created, the latest generated file is not downloading to the computer but the primary workspace questionnaire is downloading.

My new workspace name is “asp” and I have to download generated file from this workspace and I tried the following things:
my API has both of my workspace enabled and questionnaire identity is from asp workspace
1)
import ssaw
clientA = ssaw.Client(‘server website’, ‘expapi’, ‘password’)
from ssaw import ExportApi
filename = ExportApi(clientA).get(export_type=“SPSS”, questionnaire_identity=“31e56faf-4d2b-4eb8-ab2f-698948720f98$1”)

In this method their is no any error but the file is not downloading

import ssaw
clientA = ssaw.Client(‘server website/asp/’, ‘expapi’, ‘password’)
from ssaw import ExportApi
filename = ExportApi(clientA).get(export_type=“SPSS”, questionnaire_identity=“31e56faf-4d2b-4eb8-ab2f-698948720f98$1”)

In this method I get a long HTML error message saying “Not Found”

How Do I Download the generated file from another workspace?

Check if your API user is given access (by admin user) to the newly created workspace.

yes ,as I have mentioned in the query, my API is enabled for both of my workspaces

I would also like to mention that when I run the code to display the name of all the questionnaire:

for q in ssaw.QuestionnairesApi(clientA).get_list():
print(q.title)

only the questionnaire from primary workspace is displayed.

You never specified what version of the package do you have. I tried now with 21.01 server with the latest package (0.4.3) and workspaces in the url was correctly processed, i.e. url/primary gave me the list of questionnaires from primary, and url/secondary from the secondary…

I am using 21.01.6 (build 30724) server and 0.4.3 version ssaw module. .and yes url/primary gives list of questionnaire from primary and /secondary gives list from secondary. but I am having issue downloading the latest generated file from secondary workspace whereas there is no problem downloading file from primary workspace

Ah, I saw your earlier message

and only looked at the questionnaires list…

OK, now can also replicate the issue with export. To jump to the solution, please use the workspace parameter instead of directly including it in the url. i.e. run:

clientA = ssaw.Client(url='server website', api_user='expapi',
                      api_password='password', workspace='asp')

and you should get what you expect.

Little more explanation: both, Survey Solutions and ssaw client contain code to add ‘primary’ as a default workspace if one was not explicitly provided. When you directly make a web request to the Survey Solutions api endpoint (say to http://server website/asp/api/v2/export) this request will work. But for the ssaw, url=‘server website/asp’ may mean that your application is simply hosted in the /asp/ subfolder.

There are users still running pre-workspace version of 20.* of Survey Solutions and using ssaw with it, thus the need to have an explicit workspace parameter instead of assuming it is always included in the url.

thanks for the solution zurab

3 posts were split to a new topic: Getting export data using Python

3 posts were merged into an existing topic: Getting export data using Python