Error when doing exports with current version of ssaw

Am having trouble with Export function in ssaw. I have created reprex here. Any assistance please?

from ssaw import Client, models, ExportApi, QuestionnairesApi


url = 'https://mosotieno-demo.mysurvey.solutions/'
api_user = 'mosetest'
api_pass = 'Testing@2025'
workspace = 'test'

client = Client(url=url, api_user=api_user, api_password=api_pass, workspace=workspace)


for q in QuestionnairesApi(client).get_list():
    print(q.id) # Works!
    export = models.ExportJob(q, export_type='STATA') # Works!
    print(export) # Works!
    ExportApi(client).start(export, wait=True)  # Error: TypeError: Object of type Questionnaire is not JSON serializable

requirements.txt

annotated-types==0.7.0
certifi==2025.10.5
charset-normalizer==3.4.4
graphql-core==3.2.6
idna==3.11
pydantic==2.12.3
pydantic_core==2.41.4
requests==2.32.5
sgqlc==17.1
ssaw==0.7
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.5.0

I just tried to run your example (haven’t worked with this code for years, so may have a different environment than you), encountered other issues related to the version of pydantic - there was a major switch between v1 and v2 since this code was written, I have a draft version where I updated the syntax to switch to the v2 and if using that my requests went through … you must’ve seen export processes started on Friday, right?

Are you still getting the same error? what happens if you use pydantic==1.7.2?

Yes, the export started but there were errors as shown in the picture above.

I have not tried pydantic==1.7.2. Let me just do that right away!

It works with pydantic==1.7.2

annotated-types==0.7.0

certifi==2025.10.5

charset-normalizer==3.4.4

graphql-core==3.2.6

idna==3.11

pydantic==1.7.2

pydantic_core==2.41.4

requests==2.32.5

sgqlc==17.1

ssaw==0.7

typing-inspection==0.4.2

typing_extensions==4.15.0

urllib3==2.5.0
from ssaw import Client, models, ExportApi, QuestionnairesApi

url = 'https://mosotieno-demo.mysurvey.solutions/'

api_user = 'mosetest'

api_pass = 'Testing@2025'

workspace = 'test'

client = Client(url=url, api_user=api_user, api_password=api_pass, workspace=workspace)

questionnaire_id = []


for q in QuestionnairesApi(client).get_list():

    print(q.id) # Works!

    questionnaire_id.append(q.id)

    latest_q = questionnaire_id[-1] 

    export = models.ExportJob(questionnaire_id=latest_q, export_type='STATA') # Works!

    print(export) # Works!

    ExportApi(client).start(export, wait=True)  

    ExportApi(client, workspace=workspace).get(

                questionnaire_identity=latest_q,

                export_type='STATA',

                show_progress=True,

                generate=True,

                export_path='./data'

            )  # Download the exported data to the specified path

    print("Download completed successfully!")

I just uploaded version 0.8 of the ssaw package with the latest pydantic and python versions (3.10-3.14) tested. You don’t need to change anything in your setup since it works now, but if decide to update, should be fine too.

Hi @zurab adding to this, I found some issue with latest pydantic, Usually with pydantic 1.7.2 I used to write like this:

job = ExportJob(questionnaire_id=“5a99cf9de0e24e4f9da98af998129868$1”, export_type=“SPSS”, interview_status=‘All’)
r = ExportApi(client).start(job, wait=True,show_progress=True)

and the export worked perfectly, but with pydantic 2.x I found the following issues so far:

  1. in ExportJob if you dont add storage_type=None than the file will be uploaded to Onedrive as default.
  2. additionally you have to add from_date=None, to_date=None, translation_id=None even though it shows optional here, else you get error
  3. When you add wait=True it only waits for like few seconds(20 second per my counting) even though the export job isnt finished, resulting in downloading the previous generated file

I hope something can be done about this specially the wait part.

Thank you.

Update:

Downgraded ssaw to 0.7 and pydantic to 1.7.2, now works perfectly as before.

I just pushed version 0.9 out, which hopefully fixes this issue and few other related ones where optional parameters were not correctly interpreted if not specified. Should work with the latest pydantic, in case for other projects you prefer to have 2.* newer version around.

1 Like