I'm just getting back to digging into a problem that I first noticed about a month ago. Can someone verify that they are getting back valid json when doing API calls? Things are fine when I call the api directly from pasting the call in a browser but when I issue basically the exact same call from a python script I get back the raw html text from the web page and not a json formatted key value pairs like I once did.

I've been using https://www.geni.com/api and it is is no longer working for me to return json :(

Here's the relevant code snippet that used to work but it fails on the line in the code that reads. This line used to work.

info = json.loads(response.read())

I'm hoping that when posted this won't strip out the white space in the code below. An additional function takes the returned profiles id's and fetches the desired field of info need for further processing.

--Randy

## project indexer for geni.com

#mechanize will need to be downloaded and installed as a python site package, json is built into python 2.6+
import os, unicodedata, string, time, urllib, datetime
import mechanize
import json

BASE_URL = "https://www.geni.com/api/"

def getProjProfileList(project_number, page_num, count, id_list):
# Returns a list of all profile index numbers included in a project.
# string: projectNumber the last token of any geni project URL is the project number.
# string: pageNum. Passed in as a string. Geni returns multiple pages of 50 names at a time that are part of a project.
# for example an argumetnn of "2" would fetch page 2 or profiles 51-100
# int: count. Calling this proc initially with a count of 0. It will then increment this var each time a profile is
# is read giving you a count of the number of profiles included in the project.
# list of strings: idList. List of the geni id numbers found so far as returned by the API. Initially the list will be empty
# Example: idNums = profile(str(10927), 1, 0, [])