Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

635
Visualizações
'property' object is not iterable trying to get response after calling the API being used

I have this error when I am trying to get response after the call of the API I want to use.

ValueError: [TypeError("'property' object is not iterable"), 
  TypeError('vars() argument must have __dict__ attribute')]

I am trying to use fastapi in order get from the client the latitudes and longitudes so i could show the public trasnportation of that area. I could do this with an API called GeoApify. However, I have a problem and I can not find my error.

I make a request by using a dictionary in order to put all the parameters for my filter and then I convert the response to JSON. But i have this error.

 from pickletools import string1
    from fastapi import FastAPI
    import requests
    from requests.structures import CaseInsensitiveDict
    
    app = FastAPI()
    
    
    @app.get("/thanos/{lon}/{lat}")
    async def read_item(lat : float,lon : float):
        url = "https://api.geoapify.com/v2/places"
        headers = CaseInsensitiveDict()
    
        dict = {
            "categories" :   'public_transport',
            "filter"     :   'circle:' + str(lon) + ',' + str(lat) + ",500",
            "limit"      :   '20',
            "apiKey"     :   '086a77f34e3a4ed583da9606318ca0ac'
         }
    
    
        params = dict
        headers = CaseInsensitiveDict(params)
            
        headers["Accept"] = "application/json"
    
        resp = requests.get(url, headers = headers)
    
        # resp = requests.get(url = url, params = params)
        data = resp.json
        return resp
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Use as below:

from fastapi import FastAPI
import requests
from requests.structures import CaseInsensitiveDict
import urllib

app = FastAPI()

url = "https://api.geoapify.com/v2/places"

@app.get("/{lon}/{lat}")
async def read_item(lat : float, lon : float):
    params = {
       "categories" :   'public_transport',
       "filter"     :   'circle:' + str(lon) + ',' + str(lat) + ",500",
       "limit"      :   '20',
       "apiKey"     :   '086a77f34e3a4ed583da9606318ca0ac'
    }

    headers = CaseInsensitiveDict()
    headers["Accept"] = "application/json"
    
    params = urllib.parse.urlencode(params)
    resp = requests.get(url=url, params=params, headers=headers)
    
    return resp.json()
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda