ImagingDataCommons / IDC-Tutorials

Self-guided notebook tutorials to help get started with using IDC
BSD 3-Clause "New" or "Revised" License
28 stars 14 forks source link

Request failed: Forbidden when running How_to_use_IDC_APIs.ipynb #9

Closed peterwu19881230 closed 2 years ago

peterwu19881230 commented 2 years ago

Hi, dear @pieper:

I was able to generate .idc_credentials but got the error of "Request failed: Forbidden" (403 error) when running the following cell. May I get some help from you? Thanks~

filters = { "collection_id": [ "TCGA-LUAD", "TCGA-KIRC" ], "Modality": ["CT", "MR"], "race": ["ASIAN"] }

cohortSpec = {"name": "testcohort", "description": "Test description", "filters": filters}

response = requests.post(f'{idc_api_preamble}/cohorts/', json=cohortSpec, headers = head)

Check that there wasn't an error with the request

if response.status_code != 200:

Print the error code and message if something went wrong

print('Request failed: {}'.format(response.reason))

else: print(json.dumps(response.json(), sort_keys=True, indent=1))

cohort_id = response.json()['cohort_properties']['cohort_id']

fedorov commented 2 years ago

@bcli4d should be able to help with this.

If you tell me what you are actually trying to do, there may be a better way to do it.

peterwu19881230 commented 2 years ago

Yes, sure!

I am trying to used the generated credential from my local machine (.idc_credentials) to authorize and get the cohort_id.

Long term goal is to analyze the IDC data on my webpage without downloading them.

Thanks~

fedorov commented 2 years ago

Sorry for the delay in responding, I reached out to @bcli4d via other channels.

When you say "analyze the IDC data on my webpage" - what do you mean?

Did you look at the example notebooks that we have in https://github.com/ImagingDataCommons/IDC-Examples/tree/master/notebooks and for example specifically https://colab.research.google.com/github/ImagingDataCommons/IDC-Examples/blob/master/notebooks/IDC_segmentation_primer.ipynb? If you want to subset IDC data, BigQuery interface gives you a lot more capabilities than IDC API.

bcli4d commented 2 years ago

@peterwu19881230, I hope to have a revised version of idc_auth.py available later today. Apologies for the delay andl ack of communication.

bcli4d commented 2 years ago

@peterwu19881230 Please try the this revised version of idc_auth.py. Thanks.

peterwu19881230 commented 2 years ago

Hi, @bcli4d ! I just saw it and tested it. Works perfectly fine. Thank you very much @bcli4d @fedorov