Using Received Data
To make use of incoming data when that data is a single record (or single item), use the .DATA GET PARAM VALUE subroutine to retrieve each value. That will only work for single records, though. However, the API can also be used to import files in json format. Read through the --- RAWJSON memory file, and look for records where RAWJSON PATH is /data/{VariableName} - the specified data will be in RAWJSON VALUE. All are alpha fields, of course. Since json files are sequential, you can identify which field will start each record and which will end it. When you get to the last file, or when all required fields are nonblank, you can write into your target file or take whatever steps are necessary.
Sample code, importing a json file with multiple records, each with two fields containing Airline Codes and Airline Names:
BEG READ --- RAWJSON HOLD 0 KEY IS RAWJSON SNO
IF --- RAWJSON PATH EQ /data/AirlineCode
T SET SYS AIRLINE CODE = --- RAWJSON VALUE
IF --- RAWJSON PATH EQ /data/AirlineName
T SET SYS AIRLINE NAME = --- RAWJSON VALUE
T WRITE SYS AIRLINE FAIL 0
END READ --- RAWJSON
Here's a curl statement that will work to call that subroutine, assuming the subroutine is connected in Data Services to the name "SampleAPI":
curl -H "Content-Type: application/json" --data-binary @/airlineinfo.json https://serverURL.com/api/SampleAPI |