I am not able to POST() API in R. I did the following:
data <- list(request_data_type = "expression",
request_cancer_type = "all",
request_genes = c("BRCA1", "PALB2", "SRY", "TP53", "NOTCH1"),
request_models = c("CTG-0009", "CTG-0011", "CTG-0012"),
request_dataset = "PDX",
request_key = "XXX",
request_client = 99,
request_user = 99,
request_mode = 'true')
request <- POST(url = 'https://example.com/workstation',
body = data)
request
The message is
Response [https://example.com/workstation]
Date: 2021-10-11 15:33
Status: 422
Content-Type: application/json
Size: 116 B
I cannot get a status 200.
I have no problem to pull the data using Python:
import requests
import pandas as pd
data = {
"request_data_type": "expression",
"request_cancer_type": ["all"],
"request_genes": ["BRCA1", "PALB2", "SRY", "TP53", "NOTCH1"],
"request_models": ["CTG-0009", "CTG-0011", "CTG-0012"],
"request_dataset": "PDX",
"request_key": "XXX",
"request_client": 99,
"request_user": 99,
"request_mode": 'true'
}
response = requests.post('https://example.com/workstation', json=data) # this saves a .json file in the directory
df = pd.read_json('../<file_name>.json')
df.head(2)
This gives the expected result: ["this dataframe"]