I am trying to write Json data back to the SAS server. The code creates a temp file but it is empty and in the response.json() I get an error something went wrong: Unexpected token '<' ,",html> <t"... is not valid JSON. I am including both the JavaScript and the server side code. JavaScript Code: const jsonData = { "name": "value", "id": 123 }; fetch('YOUR_SAS_SERVER_ENDPOINT_URL', { /* The url is a stored process the code is listed in the method: 'POST', // Specify the method headers: { 'Content-Type': 'application/json', // Inform the server the data type 'Accept': 'application/json' // Indicate expected response type (optional) }, body: JSON.stringify(jsonData) // Convert the JS object to a JSON string }) .then(response => response.json()) // Process the response (this is where I get the error) .then(data => console.log('Success:', data)) .catch((error) => { console.error('Error:', error); }); Server Side Code; /* Reference the uploaded/posted JSON data from the input stream */ filename indata temp; /* The file gets created but 0 size and no data*/ /* Use the JSON engine to provide read-only sequential access to JSON data */ libname myjson json fileref=indata; /* Process the data (e.g., copy to a work dataset and print) */ proc copy inlib=myjson outlib=work; select alldata; /* 'alldata' is a common default table name created by the JSON engine */ run; title 'Data Received from JavaScript POST'; proc print data=work.alldata; run; /* Clear the libname reference */ libname myjson clear; /* Optionally, write a JSON response back to the client */ data _null_; file _webout type='application/json'; put '{ "status": "Data successfully received and processed by SAS" }'; run; To create the table I am using code similar to: data _null_; file _webout; put '<html>'; put '<head>'; I have tried everything specially on the server side. The Temp file is always 0 size.
... View more