Want to remove a space char in an API call where the query requires a space

StackOverflow https://stackoverflow.com/questions/22553425

  •  18-06-2023
  •  | 
  •  

سؤال

I am attempting to use www.undata-api.org/ to gather UN Health data. However, if I use their call for getting the available data sets, I get a 404 error:u'Record does not exist'

GET http://api.undata-api.org/{organization}/{database}/database_datasets?app_id= {app_id}&app_key={app_key}

but the database name is 'WHO Data' -- it has a space in it, and so this call doesn't work. I looked around a bit and saw that people had suggested replacing the space with a '%20' or a +. Neither has worked for me.

I'm using urllib2 in python for this project.

هل كانت مفيدة؟

المحلول

You need to use urllib.quote(YOUR_URL) to escape the URL for HTTP. Remember to import urllib.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top