BookmarkSubscribeRSS Feed
PabloZ
Calcite | Level 5

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

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

Before trying to upload you should check that you can connect to https://*****.com.au from Python.

Can you?

 

 

DayaB
SAS Employee

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.

PabloZ
Calcite | Level 5

Hi Daya,
That GET request is succesfulllt processed:

PabloZ_0-1742253949220.png

 

PabloZ
Calcite | Level 5

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:

PabloZ_0-1742253859079.png

 

DayaB
SAS Employee

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.

joeFurbee
Community Manager

Hi @DayaB,

Did the reply from @PabloZ solve your issue? If so, we'll mark it as the solution.


Join us for SAS Community Trivia
SAS Bowl XLIX, SAS Innovate 2025
Wednesday, February 19, 2024, at 10:00 a.m. ET | #SASBowl

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 555 views
  • 0 likes
  • 4 in conversation