How to get text response in survey monkey via API

2019-06-14 02:32发布

问题:

I'm currently getting responses from SurveyMonkey using the v3 APIs...

I'm using the /collectors/{id}/responses/{id}/details call and I successfully getting the resp. BUT the resp has got the IDs and not the text values e.g.

           {
                "id": "111788228",
                "answers": [
                    {
                        "choice_id": "828117913"
                    }
                ]
            }

1) Can I get SM to send me the text answer?

2) If I can't how can I get the text value using the choice_id.

Thanks in advance.

回答1:

There isn't a way currently to get the Survey text directly with the responses. You'll have to fetch the survey details or the details for a specific question and match the choice ID with the text for that choice on your own.

GET /v3/surveys/<survey_id>

or

GET /v3/surveys/<survey_id>/pages/<page_id>/questions/<question_id>

You'll get a body back with the choices like this:

{
    ...
    "answers": {
        "choices": [{
            "id": "12345",
            "visible": true,
            "is_na": false,
            "text": "Apples",
            "position": 1
        }, ...]
    },
    ...
}

Then you can just match the id field with the choice_id field from the response.