Is it possible to trigger a REST API call and use POST and GET methods based on a condition through a BPM.
My idea is to have a REST API call to the Carriers API once a PackSlip has been shipped so i can POST the shipment details and GET the tracking number and Shipping Labels.
Service Connect supports importing references to REST APIs and subsequently calling them.
It can import a REST reference based on WADL (very legacy metadata format; SC only supports sending and accepting XML payloads), Swagger (AKA OpenAPI v2) JSON metadata with JSON payloads, and starting with SC 10.2.700 – OpenAPI v3 JSON metadata with JSON payloads.
You can also manually define the REST reference and its parameters, however when doing so your particular control of directive parameters is limited – it is not currently possible to define parameters having a structure, and only XML payloads are supported.
– So, it boils down to whether the Carriers API provides metadata, and whether that metadata is in the format SC supports.
After the reference is imported into Service Connect, you can call it from SC workflow; the method (GET/POST/PATCH/…) used to call a particular operation of the REST reference is the one defined in the metadata for that operation.
The SC workflow can be called from a BPM directive; the directive always passes all its input and output parameters into the workflow.
The workflow can be called synchronously (BPM directive waits for the response of SC workflow and the response replaces input/output parameters of the BPM directive) or asynchronously (BPM directive does not wait for the response, just cares that the request to execute the workflow was accepted by Service Connect and continues).
If you need the tracking number to be returned from SC to the BPM directive, then you will need to:
- call the SC workflow synchronously from the BPM directive
- save all incoming data to msg:usr section (the usual way is to create a message extension holding it) to return it back to the BPM directive, otherwise there will be an error de-serializing the response
- call REST API
- Restore the data back, and put the data you want to pass back somewhere (call context or directly patch one of the fields if there’s a relevant field in one of the datasets)
- within the BPM directive, process the returned data
Note: SC is backward-compatible with Epicor, but is not forward-compatible; that is, the version of SC has to be the same or newer that thar of Epicor (barring Epicor updates) – SC 10.2.700 is compatible with Epicor 10.2.700.x or older.
yes, your idea will work. also validate the volume of the shipments. we do lot of B2B shipments/B2C. if delivery is same address (i.e amazon fulfilment center) so we consolidate packslips and pass the data to carriers api and generate 1 label rather than multiple label.