Thanks for showing me that website, I'm not used to working with SAS or APIs, and that'll be a big help. I still haven't found a solution, however, but I have a bit more information. When I run the following filename out "\\sas00750\analyse3\AKF\Data\Personlige\SIG\out.txt";
filename json_in "\\sas00750\analyse3\AKF\Data\Personlige\SIG\json_in.json";
data _null_;
file json_in recfm=f lrecl=1;
put '{"valueDate": "2021-05-10T04:32:34.394Z", "inputSpecification": "TESTINP", "name": "FOO", "parameters": [{"name": "Parameter1", "title": "My Parameter", "value": "coverstat1"}], "configuration": "TESTCONF", "scenarios": ["SCEN1"], "outputDestination": "Database"}';
run;
proc http METHOD="POST"
url="http://httpbin.org/post"
ct="application/json"
in=json_in
ct="application/json"
out=out;
headers "accept"="application/json";
run; I get this response: {
"args": {},
"data": "{\"valueDate\": \"2021-05-10T04:32:34.394Z\", \"inputSpecification\": \"TESTINP\", \"name\": \"FOO\", \"parameters\": [{\"name\": \"Parameter1\", \"title\": \"My Parameter\", \"value\": \"coverstat1\"}], \"configuration\": \"TESTCONF\", \"scenarios\": [\"SCEN1\"], \"outputDestination\": \"Database\"}",
"files": {},
"form": {},
"headers": {
"Accept": "application/json",
"Content-Length": "263",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "SAS/9",
"X-Amzn-Trace-Id": "Root=1-609a7799-4b92fc8f27fb3ea812533140"
},
"json": {
"configuration": "TESTCONF",
"inputSpecification": "TESTINP",
"name": "FOO",
"outputDestination": "Database",
"parameters": [
{
"name": "Parameter1",
"title": "My Parameter",
"value": "coverstat1"
}
],
"scenarios": [
"SCEN1"
],
"valueDate": "2021-05-10T04:32:34.394Z"
},
"origin": "",
"url": "http://httpbin.org/post"
} However, when I run the Python code that works (see original post) I get this: {
'args': {},
'data': '{"valueDate": "2021-05-10T04:32:34.394Z", "inputSpecification": "TESTINP", "name": "FOO", "parameters": [{"name": "Parameter1", "title": "My Parameter", "value": "coverstat1"}], "configuration": "TESTCONF", "scenarios": ["SCEN1"], "outputDestination": "Database"}',
'files': {},
'form': {},
'headers': {
'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate',
'Content-Length': '263',
'Content-Type': 'application/json',
'Host': 'httpbin.org',
'User-Agent': 'python-requests/2.25.1',
'X-Amzn-Trace-Id': 'Root=1-609a7993-516acbb91c5c1f902ee96668'
},
'json': {
'configuration': 'TESTCONF',
'inputSpecification': 'TESTINP',
'name': 'FOO',
'outputDestination': 'Database',
'parameters': [
{
'name': 'Parameter1',
'title': 'My Parameter',
'value': 'coverstat1'
}
],
'scenarios': [
'SCEN1'
],
'valueDate': '2021-05-10T04:32:34.394Z'
},
'origin': '',
'url': 'http://httpbin.org/post'
} Note: When I replace the single quotes with double quotes and vice versa, in the SAS program, then it doesn't seem like httpbin interprets it as json. I'm wondering if it could be an encoding issue, since the python request includes 'Accept-Encoding': 'gzip, deflate'? Is there a similar option to set in SAS? Thanks for your help.
... View more