Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I skip extracting a value that is None in Python requests

I am currently working with Python requests to get data from an API. I’m trying to have a nested request within the request depending on the value received from one of the responses. So basically, I make a request and one of the fields returned is uid. I want again to pop that value into another request and that value makes part of the url. eg. f"https://registry.nbnatlas.org/ws/dataResource/{uid}".
The only issue is that some responses have a null value for the uid field and this throws an error when making the nested request.

What I am trying to do is to skip the second request if the uid field is null

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can just add if uid is not None: before the second request

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading