I'm having trouble consuming this api, it's always giving me an error in this code here
that is a meke in python
chave_IPA = "Aqa9_KZFeRDAiAsJwyxVLQJh5tfZYeMyGHtUXEVd7PGm13xT1evy3vwA5MCcscqd"
distancia_matrix = []
for x in lista_cep:
lista = []
for j in lista_cidade:
rota = "http://dev.virtualearth.net/REST/V1/Routes/Driving?wp,0=" + x +"&mp.1=" + j +"/&key="+chave_IPA
r = requests.get(url = rota)
result = r.json()
distancia = result["resourceSets"][0]["resources"][0]['travelDistance']
lista.append(distancia)
distancia_matrix.append(lista)
matrix = pd.DataFrame(distancia_matrix)
Your
APIwhas malformed. This is the right way to do it:or like this:
which returns:
In other words:
Replace:
"http://dev.virtualearth.net/REST/V1/Routes/Driving?wp,0=" + x +"&mp.1=" + j +"/&key="+chave_IPAwith
f"http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0=redmond%2Cwa&wp.1=Issaquah%2Cwa&avoid=minimizeTolls&key={chave_IPA}"