I have this project and I know the question is dumb, but I really can't fix it. I'd really appreaciate it if someone can help me :)
import requests
import json
payload = {}
headers = {}
ll1 = 18.036442,42.492103
ll2 = 18.036808,42.117917
ll3 = 18.458814,42.485903
ll4 = 18.453989,42.115408
def make_request(payload, headers, ll1, ll2, ll3, ll4):
url = "https://api.foursquare.com/v2/venues/search?client_id=VFFCWVM5UPLGNOS3IAQHQB5LLZBIRYZTGUYW40JHKSEMM0BR" \
"&client_secret=PCF41XEGDNVIZSZT5ULESYGZUTW02TVYKX5IOAEAAMF5GYP1&v=20210927&token" \
"=AEOYTHHSPVCSNNBFRT0RCH55KVRXJ1EH2XDSXPIWEWJEMEPG&ll=" ll1 ll2 ll3 ll4 \
"&intent=browse&radius=10000 "
response = requests.request("GET", url, headers=headers, data=payload)
return response.text
data = make_request(payload, headers, ll1, ll2, ll3, ll4)
print (data)
the error I get is :
Traceback (most recent call last):
File "/Users/hessa/Desktop/main01.py", line 22, in <module>
data = make_request(payload, headers, ll1, ll2, ll3, ll4)
File "/Users/hessa/Desktop/main01.py", line 14, in make_request
url = "https://api.foursquare.com/v2/venues/search?client_id=VFFCWVM5UPLGNOS3IAQHQB5LLZBIRYZTGUYW40JHKSEMM0BR" \
TypeError: can only concatenate str (not "tuple") to str
CodePudding user response:
pass variables as string
ll1 = '18.036442,42.492103'
ll2 = '18.036808,42.117917'
ll3 = '18.458814,42.485903'
ll4 = '18.453989,42.115408'
CodePudding user response:
This should work:
import requests
import json
payload = {}
headers = {}
ll1 = "18.036442,42.492103"
ll2 = "18.036808,42.117917"
ll3 = "18.458814,42.485903"
ll4 = "18.453989,42.115408"
def make_request(payload, headers, ll1):
url = "https://api.foursquare.com/v2/venues/search?client_id=VFFCWVM5UPLGNOS3IAQHQB5LLZBIRYZTGUYW40JHKSEMM0BR" \
"&client_secret=PCF41XEGDNVIZSZT5ULESYGZUTW02TVYKX5IOAEAAMF5GYP1&v=20210927&token" \
"=AEOYTHHSPVCSNNBFRT0RCH55KVRXJ1EH2XDSXPIWEWJEMEPG&ll=" ll1 \
"&intent=browse&radius=10000"
response = requests.request("GET", url, headers=headers, data=payload)
return response.text
data = make_request(payload, headers, ll1)
data = make_request(payload, headers, ll2)
data = make_request(payload, headers, ll3)
data = make_request(payload, headers, ll4)
print (data)