Q:

Trouble posting multiple values for same key using requests in Python

I'm attempting to pass multiple values for the same key on a GET request using requests in python.  I have tried what I thought was the correct syntax, but the key is still being formatted twice in the url.
In the code that follows, I am looking to have ?tickers=ethusd,ethbtc in the url, but am getting ?tickers=ethusd?tickers=ethbtc instead:
import requests
import json
import psycopg2
from datetime import datetime    
payload = {'tickers':['ethusd','ethbtc'], 'startDate': startdate, 'endDate': enddate, 'resampleFreq': resamplefreq, 'token':token}
    requestResponse = requests.get("https:mysite",params=payload, headers=headers)

The formatted url from requests ends up as:
'https://mysite?tickers=ethusd&tickers=ethbtc&startDate=2020-05-26&endDate=2020-05-26&resampleFreq=1day&token=token'
instead of ?tickers=ethusd,ethbtc.

A:

Comma is not allowed in url. So you should encode url. I think it's a little bit complicated.
Even if you can achieve your goal, you should encode url again.
Why don't you convert array into string before setting a payload variable?
aa = ['ethusd','ethbtc']
payload = {'tickers': "-".join(aa), 'startDate': startdate, 'endDate': enddate, 'resampleFreq': resamplefreq, 'token':token}
requestResponse = requests.get("https:mysite",params=payload, headers=headers)

And you can get this value after converting into string using split method.

