kaushik guru

kaushik guru

  • 1.4k
  • 252
  • 26.7k

Unable to pass variable from payload to url in python

Oct 5 2020 11:42 PM
I am trying to pass a params named ID in to a python api function from postman which will use the ID to call another api function inside the actual api
 
but the id field remains None in postman output
 
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.xxx.com/api/v1/target/id/None/id?isidRequired=True
 
this is my code
 
@D.route('/Checkcontactinfo/', methods=['GET'])
def checkcontact():
id = request.args.get('id')
ivurl: str = f'{xxx}/id/{id}/id?'
payload: Dict[str, Union[bool, int]] = {'isIDRequired': True,
'id':id}
response = get_iv_response(url=ivurl, payload=payload)
ID_contact_totalresult: int = response.get('totalResults')
return id_contact_totalresult

Answers (2)