Uploading assignment batch files through API

Dear Survey Solutions team,

During a census with 2500 enumerators we will have to upload assignment files (containing batches of 30+ assignments) for each enumerator on a regular basis, say, once a week.
Doing this manually will be a real pain, requiring a team of people just for this task.
An API call for uploading an assignment batch file is not published on Swagger, does it maybe exist in the GraphQL API?

Alternatively, it would already be a big help if one could upload multiple batchfiles in a single upload.
Currently you can only select a single file in each upload operation.


When you upload a file, server starts reading rows and creates assignments one-by-one. Once you switch to the API route, you do the same in your code - i.e. create as many assignments as you need one after another. For (centralized) API script, batching assignments into separate groups/files doesn’t make much sense.
In both file-based and API-based assignment creation you have the responsible field that allows you to directly indicate the intended responsible user. So even when doing manually, you shouldn’t need to create multiple files, just one file where you put responsible fieldworkers’ names.

1 Like

You are right, instead of uploading a file in one API call I can make a separate call for each line of the file.
In the case of collected (potentially nested) roster data where I upload a zipfile containing several files I have no idea in which order I have to call the Create-Assignment API call on these files.
One line from the top level file followed by n lines from the first roster file? For each line in the first roster file m lines from the nested roster file?

To us creating multiple assignment batches in files does make sense. We prepare them beforehand and at the end of the week we decide who gets which batch (from many) for the next week.

Again, you shouldn’t think of files when working with api, all the data that you’d like to be a part of assignment is a payload for the single create assignment call, look at the IdentifyingData field. I don’t have anything in R (I assume that’s what you’re using) but if working in Python, you can take a look at an example of creating assignments with preloading in ssaw python package.

Your decision process of course can be this or any other, what I suggested was that, after the distribution decision is done, you can simply append those files together and have a single list of assignments with appropriate respondents to be further processed (i.e. used to create Survey Solutions assignments via GUI or a API call)

I see your point. Originally I thought of uploading these assignments through the GUI. But now I think it may be too much manual work to do that for 2500 enumerators. I’ll change my programs to focus on assignment by assignment processing.

I just found this in the swagger schema definition:

Question identity Expected format: GuidWithoutDashes_Int1-Int2, where _Int1-Int2 - codes of parent rosters (empty if question is not inside any roster). For example: 11111111111111111111111111111111_0-1 should be used for question on the second level

This seems to show the way to include the roster variables.
I am not sure what is meant by ‘codes of parent rosters’, the _0-1 part. Is it just 0 and 1 for highest and next level rosters, or should they be replaced by the roster ids (eg. abf1b6ccb8fe54218ed5111bb16c9449)?


Consider your questionnaire (data) structure:

q1. region
r1. members
        q2. name
        q3. age

you’d like to preload region code, as well as name and age for two members of the household, identifying data part of the payload will then be:

"IdentifyingData": [
      "Identity": "abf1b6ccb8fe54218ed5111bb16c9449",
      "Answer":"North region"
      "Identity": "11f830737ff4bc41a4ffe792d073f41f_0",
      "Identity": "11f830737ff4bc41a4ffe792d073f41f_1",
      "Identity": "c55e00f31561416692e51f7d6d5548ea_0",
      "Answer": 46
      "Identity": "c55e00f31561416692e51f7d6d5548ea_1",
      "Answer": 50

Where abf1b6ccb8fe54218ed5111bb16c9449 is question id of ‘region’, 11f830737ff4bc41a4ffe792d073f41f is question id of ‘name’, and c55e00f31561416692e51f7d6d5548ea is id for ‘age’. 0 is the row index for Jane and 1 is for John. These are the indices as you’d put in your members file if you were to prepare zipped data for GUI upload.

1 Like

Okay, thank you, this is a clear explanation.
So what is called “codes of parent rosters” are the roster indices for the roster item to be preloaded.
Thanks again,