Hi,
I am trying to set up a custom app with a module that processes multiple http GET requests to output data from multiple endpoints within one module. This is because the software has too many nested API endpoints that increases the operations consumed if i run the individual endpoints as separate modules.
I have set everything right in the custom app’s module page, and everything works fine, but when there is a 404 error which sometimes happens if a particular endpoint doesn’t exists for that particular batch, the whole module returns an error.
How can I ignore that particular endpoint and proceed to process others so the module returns only data from the successful GET requests.
Here is the current code i’m using in the communication section of the module:
[
{
// Step 1: GET Appointment
"qs": {
"{{...}}": "{{toCollection(parameters.qs, 'key', 'value')}}"
},
"url": "https://api.{{connection.apiShard}}.cliniko.com/v1{{parameters.url}}",
"method": "GET",
"response": {
"temp": {
"appointment_data": "{{body}}",
"appointment_type": "{{body.appointment_type.links.self}}",
"business": "{{body.business.links.self}}",
"practitioner": "{{body.practitioner.links.self}}",
"attendees": "{{body.attendees.links.self}}",
"referring_doctor": "{{body.referring_doctor.links.self}}",
"patient": "{{body.patient.links.self}}"
}
}
},
// Step 2: GET Appointment Type
{
"url": "{{temp.appointment_type}}",
"method": "GET",
"response": {
"temp": {
"appointment_type": "{{body}}"
}
}
},
// Step 3: GET Patient
{
"url": "{{temp.patient}}",
"method": "GET",
"response": {
"temp": {
"patient_data": "{{body}}",
"patient_id": "{{body.id}}"
}
}
},
// Step 4: GET Marketing Referral
{
"url": "https://api.{{connection.apiShard}}.cliniko.com/v1/patients/{{temp.patient_id}}/referral_source",
"method": "GET",
"response": {
"temp": {
"marketing_referral": "{{body}}"
}
}
},
// Step 5: GET Practitioner
{
"url": "{{temp.practitioner}}",
"method": "GET",
"response": {
"temp" :{
"practitioner_data": "{{body}}"
},
"output": {
"Practitioner": "{{body}}",
"Appointment": "{{temp.appointment_data}}",
"Appointment Type": "{{temp.appointment_type}}",
"Patient": "{{temp.patient_data}}",
"Marketing Referral":"{{temp.marketing_referral}}",
"headers": "{{headers}}",
"statusCode": "{{statusCode}}"
}
}
}
]
In the code above, if Step 4 (Marketing Referral) doesn’t exist (returns 404), The module returns an error. What I want is for the error to be ignored (or return empty) and the code processing to continue on to step 5 (Get Practitioner) and return an output.
Any help will be greatly appreciated.