Hi All,
SAS version: SAS Viya LTS 2023.9
I am trying to make an API call to upload a file and create a table. I am using this link as a reference: https://developer.sas.com/rest-apis/dataTables/createTableFromMultipart.
I am doing this through Postman for testing purposes, here is code in Python:
import requests
url = "https://*****.com.au/dataTables/dataSources/Compute~fs~be7240bc-96e9-4eff-b3f9-ba9e23d7d3b2~fs~WORK/tables"
payload = {'tableRequest': '{
"sourceArguments": {
"delimiter": ",",
"firstRowHasColumnNames": true
},
"targetArguments": {
"tableName": "IMPORT_TEST_NONADMITTED_TEST",
"replace": true,
"columnDefinitions": [
{ "name": "RecordID", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "T2Clinicv7", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "fundingsource", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "STATE", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "indstat", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "bir_date", "type": "date", "informat": "DDMMYY8.", "format": "DDMMYY8." },
{ "name": "service_date", "type": "date", "informat": "DDMMYY8.", "format": "DDMMYY8." },
{ "name": "Postcode", "type": "character", "length": 6 },
{ "name": "SA2", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "pat_multiprov_flag", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "est_eligible_paed_flag", "type": "numeric", "informat": "BEST32.", "format": "BEST12." },
{ "name": "estabid", "type": "character", "length": 9 }
]
}
}'}
files=[
('file',('test_data_non_admitted.csv',open('/C:/****/test_data_non_admitted.csv','rb'),'text/csv'))
]
headers = {
'Content-Item-Type': 'application/vnd.sas.data.table.cas.delimited.request+json',
'Content-Type': 'multipart/form-data',
'Authorization': '***********',
'Cookie': '***********'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)Thi is the response I am receiving:
{
"httpStatusCode": 503,
"errorCode": 11916,
"message": "The provider for the source \"Compute~fs~be7240bc-96e9-4eff-b3f9-ba9e23d7d3b2~fs~WORK\" is not available, or it is currently starting up.",
"details": [
"path: /dataTables/dataSources/Compute~fs~be7240bc-96e9-4eff-b3f9-ba9e23d7d3b2~fs~WORK/tables",
"correlator: 65510512-b779-484e-8c1a-eef71fa7bac9"
]
}Any ideas of how to make this work will be appreciated.
Thanks!
Pablo
Hello Pablo,
Now I see the issue. You are trying to create a table using Compute provider. Unfortunately Compute provider (service) is not registered with capability for creating tables. Currently only cas provider allows table creation. You can try creating the table in cas.
Before trying to upload you should check that you can connect to https://*****.com.au from Python.
Can you?
The said error is returned when Compute service is unavailable. To verify it is running, see if GET https://*****.com.au/dataSources/providers/Compute/sources request is successfully processed.
Hi Daya,
That GET request is succesfulllt processed:
I am running the test through Postman and I am able to make API calls succesfully, I can even run jobs from the API, my issue is trying to upload a file to create a table.
Here is an example showing that a GET call is working:
Hello Pablo,
Now I see the issue. You are trying to create a table using Compute provider. Unfortunately Compute provider (service) is not registered with capability for creating tables. Currently only cas provider allows table creation. You can try creating the table in cas.
Hi @PabloZ @,
Did the reply from @DayaB @ solve your issue? If so, we'll mark it as the solution.
Join us for SAS Community Trivia
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.