0

I am accessing the class from the code api_service.py, which can be found here. When I call the first function, I have no problem, because no variables are passed:

from api_service import ApiService
import json

def main():

    api_key = *removed*
    access_token = *removed*

    calling = ApiService(api_key,access_token)
    survey_list = calling.get_survey_list()

But when I use the same type of routine as above to call a function from ApiService that requires a variable, I'm told that I should pass an object.

    survey_details = calling.get_survey_details("1234")
    survey_details = json.loads(json.dumps(survey_details))
    print survey_details

The specific error message:

{u'status': 3, u'errmsg': u"Value '1234' for field '_data' is not of type object"}

Details for the get_survey_details aspect of the SurveyMonkey API are here, although I think a python-guru can solve this without knowing about the API.

Marcin
  • 48,559
  • 18
  • 128
  • 201
philshem
  • 24,761
  • 8
  • 61
  • 127
  • 3
    Did you forget a word in your title? Can you please fill it in, it's loss is – Martijn Pieters Aug 13 '13 at 14:19
  • 4
    Just a guess: did you try `get_survey_details(survey_id="1234")`? (And if that doesn't work, please try `get_survey_details({"survey_id": "1234"})`. – David Robinson Aug 13 '13 at 14:21
  • Either what @DavidRobinson said, or the call requires a JSON string, and thus a JSON object for the data. That would be symmetrical of the API, given that it appears to return a JSON string on the other end as well. – Silas Ray Aug 13 '13 at 14:22
  • Problem quickly solved thanks to your help. Thanks. – philshem Aug 13 '13 at 14:23

1 Answers1

2

This is a javascript/json object:

{field:'value'}

You have passed a string which, doesn't count as an "object" for these purposes.

Note that the error message is being generated by the service you are accessing. This question would be better directed to the creator of the service.

Marcin
  • 48,559
  • 18
  • 128
  • 201