Callbacks
A Callback is a request that originates from the Foresight REST API server and is sent to the client in response to an earlier request sent by that client. Foresight REST API supports 4 main types of callbacks.
Mid-Processing Callback
You can initiate a callback with Foresight REST API when starting a Validation or Translation process. This callback occurs after the data file header has been parsed, and it sends information about the data to another process that can then return one or more guidelines, map, and so on, for use in the subsequent Validation and Translation processing.
Data sent to external system via POST from Foresight REST API Instream/Translator Callback
JSON Format
{
"sourceOp": "T",
"jobId": "J200716171357_00001",
"tag": "Inbound",
"protocol": "X12", "txnInfo": {
"interchange": { "date": "110924",
"receiverQualifier": "01",
"senderID": "9012345720000",
"receiverID": "9088877320000",
"senderQualifier": "01",
"ctlNo": "000000370",
"date": "110924",
"time": "0947",
"version": "00501"
},
"functionalGroup": { "date": "20110924",
"receiver": "908887732000",
"sender": "901234572000",
"ctlNo": "370",
"groupID": "HC",
"time": "1615", "version": "005010X223A2"
},
"transactionSet": { "transactionSetID": "837"
}
},
"textInfo": {
"receiverDomain": "01",
"senderID": "123456789",
"receiverID": "987654321", "messageType": "PEDIDOAUTEXT", "recordDelimiter": "0x27", "fieldDelimiter": "", "messageGroup": "TEXT",
"key": "S1",
"senderDomain": "01"
}
}
Text Format
<?xml version="1.0" encoding="UTF-8"? <Info id="X12"> <Interchange> <SenderQualifier>01</SenderQualifier> <Sender>9012345720000</Sender> <ReceiverQualifier>01</ReceiverQualifier> <Receiver>9088877320000</Receiver> <Date>110924</Date> <Time>0947</Time> <CtlNo>000000370</CtlNo> <ICVersion>00501</ICVersion> </Interchange> <FunctionalGroup> <ID>HC</ID> <Sender>901234572000</Sender> <Receiver>908887732000</Receiver> <Date>20110924</Date> <Time>1615</Time> <CtlNo>370</CtlNo> <Version>005010X223A2</Version> </FunctionalGroup> <TransactionSet> <TransactionSetID>837</TransactionSetID> </TransactionSet> </Info> <Source> <Op>T</Op> <Job>J200716103132_00002</Job> <Tag>Inbound</Tag> </Source>
Data to be returned to Foresight REST API
The POST response from the external system supports returning data to Foresight REST API Instream/Translator Callback. The following examples show the JSON and text format of the data.
JSON Format
{
"senderName": "string", "receiverName": "string", "operationInfo": {
"validationGuidelineID": "string", "validationProfileID": "string", "translationMapID": "string", "sourceGuidelineID": "string", "targetGuidelineID": "string", "translationType": "string"
}
}
Text Format
senderName=string receiverName=string validationGuidelineID=string validationProfileID=string translationMapID=string sourceGuidelineID=string targetGuidelineID=string translationType=code
| Parameters | Description |
|---|---|
senderName
|
Optional Name of the person who sends the data. |
receiverName
|
Optional Name of the person who receives the data. |
validationGuidelineID
|
Required This is required when validation is to be performed. If both translation and validation are to be performed and this parameter is omitted, the target guideline is used for validation. |
validationProfileID
|
Optional ProfileID is required to perform validation. |
translationMapID
|
Required Map ID, is required to perform translation. |
sourceGuidelineID
|
Optional If omitted, the sourceGuideline from the map specified in mapID is used. |
targetGuidelineID
|
Optional If omitted, a target guideline from the map specified in mapID is used. |
translationType
|
Optional If omitted, it is automatically determined from the source and target guidelines. The valid codes include: EE - EDI to EDI EX - EDI to XML EF - EDI to Flat XE - XML to EDI XF - XML to Flat FE - Flat to EDI FX - Flat to XML FF - Flat to Flat |
File Request Callback
When Foresight REST API cannot find a specified file on its system, it sends a File Request GET to an external process on job completion using the File Request Callback. The file name and resource type are passed in the query:
http://xxx/fileName?type=t
Where:
| xxx | File Request Callback server URL. |
| filename | The name of the file requested. |
| t |
A code corresponding to the resource type of the file: c = controlfile d = datafile g = guideline m = map |
For example:
GET http://<host-name>:<port>/CallbackTesterREST/FileReq/my4010_837.std?type=g is requesting the guideline file my4010_837.std.
Notification Callback
Foresight REST API can send a notification to an external process on job completion using the NotifyCallback. The information contained in the Notification POST includes information about the job, various status codes, and the output files it produced.
Data sent to external system via POST from Foresight REST API Notification Callback
JSON Format
{
"sourceOp": "string", // I or T "jobId": "string", // Job ID
"status": "string", // COMPLETE (only notification event so far) "started": "string", // yyyy-mm-dd hh:mm:ss.mmm+/-tttt "completed": "string", // yyyy-mm-dd hh:mm:ss.mmm+/-tttt
"ops": "string", // I, T, IT, TI "instreamRCode": "string",
"instreamMsg": "string",
"instreamMsgsBySeverity": "string", // n,n,n,n,n,n,n "instreamMsgsByWEDIType": "string", // n,n,n,n,n,n,n
"translatorRCode": "string", "translatorMsg": "string",
"outputFiles": // Used only when output files are present [
"fileName1", "fileName2", "fileName3",
...
"fileNameN",
]
}
TEXT Format
SourceOp:string // I or T JobID:string // Job ID Status:string // COMPLETE (only notification event so far) Started:string // yyyy-mm-dd hh:mm:ss.mmm+/-tttt Completed:string // yyyy-mm-dd hh:mm:ss.mmm+/-tttt Ops:string // I, T, IT, TI InstreamRCode:string InstreamMsg:string InstreamMsgsBySeverity:string // n,n,n,n,n,n,n InstreamMsgsByWEDIType:string // n,n,n,n,n,n,n TranslatorRCode:string TranslatorMsg:string --OutputFiles-- fileName1 fileName2 fileName3 ... filename
Data to be returned to Foresight REST API via POST response from External System to Foresight REST API Notification Callback
No data is returned. Instead, an HTTP return code indicates success or failure.
Message Callback
Foresight REST API can POST messages to an external process at various times using Message Callback. The information contained in the Message POST includes the Job ID, Business Area, Message Title and Description, the message date and time, information about the job, various status codes, and the output files it produced. The only format that Foresight REST API currently handles is the BCCE/AuditSafe format.
INSTREAM_VALIDATION_ERROR is 20.Data sent to external system via POST from Foresight REST API Message Callback
[{
"transaction_id":"J230707142635_00001", // Job ID "biz_proc":"FR_J", // Business Area
"audit_event":"Job Completed", // Title "event_desc":"Job posting process completed", // Description "event_timestamp":"2023-07-07T14:26:36.440-04:00", // Date and time "event_status":"FAILED" // Status
}]
Data to be returned to Foresight REST API via POST response from External System to Foresight REST API Message Callback
No data is returned. Instead, an HTTP return code indicates success or failure.