[Python] 'property' object is not iterable trying to get response after calling the API being...

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    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

    Continue reading...

Compartilhe esta Página