I want to return a JSON object from this URL. I correctly pass in my API but when I go to do
data=json.loads(a.read())
print data
I get this error
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.1\lib\bdb.py", line 387, in run
exec cmd in globals, locals
File "<module1>", line 1, in <module>
from urllib2 import Request, urlopen
File "C:\Python27\ArcGIS10.1\lib\json\__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "C:\Python27\ArcGIS10.1\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\ArcGIS10.1\lib\json\decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
here is my full code
from urllib2 import Request, urlopen
import urllib2
import json
apikey='abid'
url='https://search.onboard-apis.com/propertyapi/v1.0.0/sale/detail?address1=586+FRANKLIN+AVE&address2=brooklyn+NY+11238'
weburl=Request(url)
weburl.add_header('apikey',apikey)
a=urlopen(weburl)
data=json.loads(a.read())
print data
https://developer.onboard-apis.com/docs documentation
this question has not helped Python urllib2: Receive JSON response from url
this is what a.read() prints
<Response>
<status>
<version>1.0.0</version>
<code>0</code>
<msg>SuccessWithResult</msg>
<total>1</total>
<page>1</page>
<pagesize>10</pagesize>
</status>
<property>
<identifier>
<obPropId>8831109036047</obPropId>
<fips>36047</fips>
<apn>011340051</apn>
<apnOrig>1134 51</apnOrig>
</identifier>
<lot>
<depth>80</depth>
<frontage>20</frontage>
<lotnum>51</lotnum>
<lotsize1>0.0367</lotsize1>
<lotsize2>1600</lotsize2>
</lot>
<area>
<blockNum>1134</blockNum>
<countrysecsubd>Kings County</countrysecsubd>
<countyuse1>B3</countyuse1>
<muncode>27</muncode>
<munname>CROWN HEIGHTS</munname>
<srvySection>04</srvySection>
<srvyTownship>07</srvyTownship>
<taxcodearea>1</taxcodearea>
</area>
<address>
<country>US</country>
<countrySubd>NY</countrySubd>
<line1>586 FRANKLIN AVE</line1>
<line2>BROOKLYN, NY 11238</line2>
<locality>Brooklyn</locality>
<matchCode>ExaStr</matchCode>
<oneLine>586 FRANKLIN AVE, BROOKLYN, NY 11238</oneLine>
<postal1>11238</postal1>
<postal2>3351</postal2>
<postal3>C008</postal3>
</address>
<location>
<accuracy>Street</accuracy>
<elevation>0</elevation>
<latitude>40.678325</latitude>
<longitude>-73.955376</longitude>
<distance>0</distance>
<geoid>CO36047,CS3610022,DB3600095,MT30004136,ND0000006436,ND0000499119,PL3651000,SB0000105657,SB0000106357,ZI11238</geoid>
</location>
<summary>
<absenteeInd>SITUS FROM SALE (ABSENTEE)</absenteeInd>
<propclass>"Duplex, Triplex, Quadplex)"</propclass>
<propsubtype>TWO FAMILY</propsubtype>
<proptype>DUPLEX</proptype>
<yearbuilt>0</yearbuilt>
<propLandUse>DUPLEX</propLandUse>
<propIndicator>21</propIndicator>
</summary>
<utilities />
<building>
<size>
<bldgsize>0</bldgsize>
<grosssize>3200</grosssize>
<grosssizeadjusted>0</grosssizeadjusted>
<groundfloorsize>0</groundfloorsize>
<livingsize>0</livingsize>
<sizeInd>GROSS SQFT</sizeInd>
<universalsize>3200</universalsize>
</size>
<rooms>
<bathfixtures>0</bathfixtures>
<baths1qtr>0</baths1qtr>
<baths3qtr>0</baths3qtr>
<bathscalc>0</bathscalc>
<bathsfull>0</bathsfull>
<bathshalf>0</bathshalf>
<bathstotal>0</bathstotal>
<beds>0</beds>
<roomsTotal>0</roomsTotal>
</rooms>
<interior>
<bsmtsize>0</bsmtsize>
<fplccount>0</fplccount>
</interior>
<construction />
<parking>
<prkgSize>0</prkgSize>
<prkgSpaces>0</prkgSpaces>
</parking>
<summary>
<bldgsNum>1</bldgsNum>
<bldgType>TWO FAMILY</bldgType>
<levels>3</levels>
<storyDesc>TWO FAMILY</storyDesc>
<unitsCount>4</unitsCount>
<yearbuilteffective>1910</yearbuilteffective>
</summary>
</building>
<vintage>
<lastModified>2016-5-24</lastModified>
<pubDate>2016-5-24</pubDate>
</vintage>
<sale>
<salesearchdate>2016-1-27</salesearchdate>
<saleTransDate>2016-1-27</saleTransDate>
<amount>
<saleamt>1650000</saleamt>
<salerecdate>2016-2-10</salerecdate>
<saledisclosuretype>0</saledisclosuretype>
<saledocnum>46760</saledocnum>
<saletranstype>Resale</saletranstype>
</amount>
<calculation>
<priceperbed>0</priceperbed>
<pricepersizeunit>516</pricepersizeunit>
</calculation>
<ownershiptransferpercentage>0</ownershiptransferpercentage>
<resaleornewconstruction>M</resaleornewconstruction>
<cashormortgagepurchase>M</cashormortgagepurchase>
</sale>
</property>
</Response>