Skip to content

Instantly share code, notes, and snippets.

@jag3773
Created March 26, 2015 22:26
Show Gist options
  • Save jag3773/f3f03f6c1bbbd4ab1b31 to your computer and use it in GitHub Desktop.
Save jag3773/f3f03f6c1bbbd4ab1b31 to your computer and use it in GitHub Desktop.
JSON Post Error
>>> data
{'content': u'https://api.unfoldingword.org/obs/txt/1/es/obs-es.json?date_modified=20141208', 'sig': u'MGUCMQDnCIED/Rzt09WRBvC8ngxLNGOYaWC4dWJkGnuYwkiLYR+hvyogDlx+v+YVaFiRUvcCMGKQD3FjJpspjVJQsbfEW7z2OIOmrGRyDIWzb6TbAnCCj1Gn00JRidI3SgUomSd8eQ==', 'slug': u'uW'}
>>> payload = json.dumps(data)
>>> payload
'{"content": "https://api.unfoldingword.org/obs/txt/1/es/obs-es.json?date_modified=20141208", "sig": "MGUCMQDnCIED/Rzt09WRBvC8ngxLNGOYaWC4dWJkGnuYwkiLYR+hvyogDlx+v+YVaFiRUvcCMGKQD3FjJpspjVJQsbfEW7z2OIOmrGRyDIWzb6TbAnCCj1Gn00JRidI3SgUomSd8eQ==", "slug": "uW"}'
>>> req = urllib2.Request(api, payload, {'Content-Type': 'application/json'})
>>> f = urllib2.urlopen(req)
>>> response = f.read()
>>> f.close()
>>> response
'{"error": "expected string or buffer"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment