I am trying to place a variable into a POST request using the Requests library. Here is my code:
import requests
message = "if i can\'t let it go out of my mind"
split_message = message.split()
initial_request = requests.get('http://ws.spotify.com/search/1/track?q='.join(split_message[:3]))
print initial_request.content
The outcome I am getting is this (which is an error, as it is messing up the URI):
No connection adapters were found for 'ifhttp://ws.spotify.com/search/1/track?q=ihttp://ws.spotify.com/search/1/track?q=can't'
I would like the request URI to look like this:
"http://ws.spotify.com/search/1/track?q=if i can\'t"
What am I missing here? Is there a better way to pass a variable to the request URI? I tried using a dictionary as the payload, but I can't place a variable into a dictionary.