title: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) - Error only occurs when code is nested
body: <p>I am currently working on a project that retrieves data about car auctions, I have it set up to request a custom Ebay URL that uses their api, I request the page and convert it to a JSON for handling. The code runs with no errors at all if the code is by itself but if I put it within a function or within a conditional statement or anything else that means it is nested it will give me the JSON error 
  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  My code is here, however I dont know if it is an issue with my code as it works fine when it is not within a function</p>
  
  <pre><code>ebayurl = "http://svcs.ebay.com/services/search/FindingService/v1?\
  SECURITY-APPNAME=KyleOsbo-CarSearc-PRD-adf6708f9-c75353fe\
  &amp;OPERATION-NAME=findItemsAdvanced\
  &amp;SERVICE-VERSION=1.13.0\
  &amp;GLOBAL-ID=EBAY-GB\
  &amp;RESPONSE-DATA-FORMAT=JSON\
  &amp;REST-PAYLOAD\
  &amp;categoryId(0)=9801\
  &amp;outputSelector(0)=SellerInfo\
  &amp;keywords="+"honda%20civic" #The custom url was created based on my needs, I only want to search ebay uk and only within the cars category
  
  apiResult = requests.get(ebayurl) #Request the custom url
  parsedresult = apiResult.json() #Convert url to json format in order to extract information easier
  for item in (parsedresult["findItemsAdvancedResponse"][0]["searchResult"][0]["item"]): #JSON is set up as multi dimensional array, looks within it to extract values
      title = item["title"][0]
      price = item["sellingStatus"][0]["convertedCurrentPrice"][0]["__value__"]
      itemURL = item["viewItemURL"][0]
      location = item["location"][0]
      itemid = item["itemId"][0]
      with sqlite3.connect("results.db") as db: #Connecting to table ready to insert new records
          cursor = db.cursor()
          values = (itemid, title, price, location, itemURL) #Declaring values that will be inserted,preventing sql injection, these values will change upon every iteration
          sql = """ INSERT INTO ebay_results(item_id, title, price, location, itemURL)
                  VALUES(?,?,?,?,?)
                  """
          cursor.execute(sql, values) #Inserts a new record for every item found
          db.commit()
  </code></pre>
  
  <p>The error occurs at
      parsedresult = apiResult.json()</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\ikoze\Documents\Computer Science\Coursework 
  files\carrySearch.py", line 94, in &lt;module&gt;
      parsedresult = apiResult.json() #Convert url to json format in order to 
  extract information easier
    File "C:\Users\ikoze\AppData\Local\Programs\Python\Python36-32\lib\site- 
  </code></pre>
  
  <p>packages\requests\models.py", line 892, in json
          return complexjson.loads(self.text, **kwargs)
        File "C:\Users\ikoze\AppData\Local\Programs\Python\Python36- 
      32\lib\json__init__.py", line 354, in loads
          return _default_decoder.decode(s)
        File "C:\Users\ikoze\AppData\Local\Programs\Python\Python36- 
      32\lib\json\decoder.py", line 339, in decode
          obj, end = self.raw_decode(s, idx=_w(s, 0).end())
        File "C:\Users\ikoze\AppData\Local\Programs\Python\Python36- 
      32\lib\json\decoder.py", line 357, in raw_decode
          raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)</p>