REST errors
Scenario

How does this work
REST API
REST
Detail
Function
provider: DATA_PROVIDER_REST
# Create new record in the backend
method: POST
# Use your REST service URL
url: https://[your_rest_service]/api/customers
# Direct the function call to use local execution,
# between the mobile device and the REST service.
useLocalCall: true
parameters:
x-functions-key:
location: header
required: false
type: string
# Use manage.jigx.com to define credentials for your solution.
value: service.oauth
firstName:
type: string
location: body
required: true
lastName:
type: string
location: body
required: true
companyName:
type: string
location: body
required: true
address:
type: string
location: body
required: false
city:
type: string
location: body
required: false
state:
type: string
location: body
required: false
zip:
type: string
location: body
required: false
phone1:
type: string
location: body
required: false
phone2:
type: string
location: body
required: false
email:
type: string
location: body
required: false
web:
type: string
location: body
required: false
region:
type: string
location: body
required: false
customerType:
type: string
location: body
required: false
jobTitle:
type: string
location: body
required: false
inputTransform: |
{
"firstName": firstName,
"lastName": lastName,
"companyName": companyName,
"address": address,
"city": city,
"state": state,
"zip": zip,
"phone1": phone1,
"phone2": phone2,
"email": email,
"web": web,
"region": region,
"customerType": customerType,
"jobTitle": jobTitle
}
outputTransform: |
{
"id": custId,
"status": status
}
# Configure multiple REST error responses.
error:
# Configure the specific REST endpoint error that is returned.
- when: [email protected] = 401
# Choose an icon to show in the error message.
icon: on-error-sad
# Provide a short meaningful title for the error.
title: Oops! Something Went Wrong
# Describe a user-friendly explanation for the error.
description: "It seems like you don’t have permission to Add customers.
If you think this is a mistake, please contact support. We’re here to help!"
details: =('Error:' & ' ' & @ctx.response.statusText & ' (' &
@ctx.response.status & ')')
# Write the error to the customer_error table
table: [email protected] & "_error"
# Send a notification to the app user using the title, description,
#detail and icon properties.
notification: true
# Specifiy what data must be written in the error table.
transform:
'={ "id": @ctx.commandId, "type": "System Offline",
"screen": "system-offline", "response": @ctx.response,
"request": @ctx.request, "user": @ctx.user, "solution": @ctx.solution,
"entity": @ctx.entity, "correlationId": @ctx.correlationId}'
# Add the number of retries and the time between each retry.
retry:
delay: "=(@ctx.response.headers.'retry-after' ? $number(@ctx.response.headers.'retry-after') : 5) * 1000"
maxRetries: 3
# Configure the next error that could be returned from the REST endpoint.
- when: [email protected] = 403
title: System Offline
description:
It looks like our system is temporarily unavailable.
We're working hard to fix this and get things back on
track. Please try again in a little while. Thank you
for your patience!
details: [email protected]
icon: server-error-403-hand-forbidden
notification: true
table: [email protected] & "_error"
transform:
'={ "id": @ctx.commandId, "type": "System Offline",
"screen": "system-offline", "response": @ctx.response,
"request": @ctx.request, "user": @ctx.user, "solution": @ctx.solution,
"entity": @ctx.entity, "correlationId": @ctx.correlationId}'
# All other returned REST endpoint errors will be caught
# under the Unexpected error section.
- title: Unexpected error
description:
An unexpected error occurred. Support has been notified and will
reach out via email once the issue is resolved.
details: [email protected]
# Set an automatic retry, specify the delay befre the retry is actioned,
# Set the number of retries allowed.
retry:
delay: "=(@ctx.response.headers.'retry-after' ? $number(@ctx.response.headers.'retry-after') : 5)*1000"
maxRetries: 3
icon:
table: [email protected] & "_error"
notification: true
transform:
'={ "id": @ctx.commandId, "type": "nexpected error",
"screen": "customer-error-500", "response": @ctx.response,
"request": @ctx.request, "user": @ctx.user, "solution": @ctx.solution,
"entity": @ctx.entity, "correlationId": @ctx.correlationId}'Datasources
Jigs (screens)
Use the commandQueue
Use the customers_error table
Index
Last updated
Was this helpful?