url_a = """http://some.url/"""
url_b = """http://some.url/'{}'/target"""
a= requests.get(url_a)
a_data = a.json()
a_id = [i['id'] for i in a_data]
b= requests.get(url_b.format(a_id[0]))
b_data = b.json()
print(b_data)
{u'message': u"Unrecognized REST Request: GET/aps/2/resources/'%5C73d49684-dc10-4d6a-ae56-eb3816cd7064'%5C/subscriptions", u'error': u'APS::Util::Exception'}
type(a_data)
<type 'list'>
URL A has some data fetched in json format, that is represented as a list of dictionaries. I need to feed that value for key 'id' into URL B but I can't do it. It's sending it as http://some.url/ '12345'/target with quotes. If I escape the quotes it is still sending literal escapes to the API controller. If I don't use quotes it returns an empty result.
A valid result is there if it's passed as /aps/2/resources/12345/subscriptions however I can't figure out how to represent it in python.
Appreciate some assistance. Thank you.
>>> s_data = s.json()
>>> print(s_data)
[]
>>> f = i_ids[0]
>>> print(f)
73d49684-dc10-4d6a-ae56-eb3816cd7064
>>> f = i_ids[1]
>>> print(f)
89c20244-331a-48c4-afea-3e23e72af768
>>> s = requests.get(s_url.format(i_ids[1]), verify=False)
>>> s_data = s.json()
>>> print(s_data)
>>> len(s_data)
143
>>>
Guys sorry but yes I just had to remove the single quotes from {}
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.