Export coded results as SPSS (.sav)
const url = 'https://api.surveycoder.io/v2/export/sav';const options = { method: 'POST', headers: { 'X-Request-Id': '550e8400-e29b-41d4-a716-446655440000', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"project_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","question_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","layout":"columns_by_mention","include_demographics":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.surveycoder.io/v2/export/sav \ --header 'Content-Type: application/json' \ --header 'X-Request-Id: 550e8400-e29b-41d4-a716-446655440000' \ --header 'x-api-key: <x-api-key>' \ --data '{ "project_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "question_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "layout": "columns_by_mention", "include_demographics": false }'Generate an SPSS .sav file for a single question’s coded results. Requires the SPSS microservice to be running on the server side.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters ”Example
550e8400-e29b-41d4-a716-446655440000Client-generated request ID for tracing. Returned as-is in the
response X-Request-Id header.
Request Body required
Section titled “Request Body required ”Options for SPSS .sav export.
object
Project to export.
Specific question to export (SPSS export is single-question).
Data layout for the .sav file:
columns_by_mention— Separate variables for 1st, 2nd, 3rd mention.binary_dummy— One 0/1 variable per code.
Include demographic variables in the .sav file.
Responses
Section titled “ Responses ”SPSS .sav file download
Headers
Section titled “Headers ”Example
attachment; filename="export-a1b2c3d4.sav"Suggested filename for the download.
Request body failed validation.
Standard error envelope.
object
object
Machine-readable error code. See the error reference for the full list.
Human-readable explanation of what went wrong.
Echo of the X-Request-Id header, when provided.
Link to documentation for this specific error code.
Example
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "responses array is required and must not be empty", "doc_url": "https://docs.surveycoder.io/errors/validation-error" }}Missing or invalid API key.
Standard error envelope.
object
object
Machine-readable error code. See the error reference for the full list.
Human-readable explanation of what went wrong.
Echo of the X-Request-Id header, when provided.
Link to documentation for this specific error code.
Example
{ "success": false, "error": { "code": "UNAUTHORIZED", "message": "x-api-key header is required", "doc_url": "https://docs.surveycoder.io/errors/unauthorized" }}Resource not found.
Standard error envelope.
object
object
Machine-readable error code. See the error reference for the full list.
Human-readable explanation of what went wrong.
Echo of the X-Request-Id header, when provided.
Link to documentation for this specific error code.
Example
{ "success": false, "error": { "code": "NOT_FOUND", "message": "Project not found", "doc_url": "https://docs.surveycoder.io/errors/not-found" }}SPSS microservice error
Standard error envelope.
object
object
Machine-readable error code. See the error reference for the full list.
Human-readable explanation of what went wrong.
Echo of the X-Request-Id header, when provided.
Link to documentation for this specific error code.
Example
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "responses array is required and must not be empty", "doc_url": "https://docs.surveycoder.io/errors/validation-error" }}SPSS service not configured
Standard error envelope.
object
object
Machine-readable error code. See the error reference for the full list.
Human-readable explanation of what went wrong.
Echo of the X-Request-Id header, when provided.
Link to documentation for this specific error code.
Example
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "responses array is required and must not be empty", "doc_url": "https://docs.surveycoder.io/errors/validation-error" }}