Using makeen transform Connectors, enterprises can integrate a variety of business systems with their mobile forms. The REST (Representational State Transfer) Connector enables the integration of systems which use RESTful APIs as a data source.
Currently, the REST Connector can be configured for the GET HTTP method. This means form data cannot be passed through it. Moreover, the connector does not support authentication at the moment. That said, a fully-functional REST Connector is part of our future development plan.
This article explains how you can configure the REST Connector to fetch data from an Entity. Please note we have used the public URL
http://jsonplaceholder.typicode.com/todos to display the To-Do list in the example below.
Step 1 - Configure the Connector's Settings
To configure the settings of the REST Connector:
- Click on Connections in transform Studio. Select the REST Connector from the list depicted below.
- Type a name for the Connector in the Connection Name field.
- Type the main URL of the service in the Service URL field. For this example, copy and paste this URL: http://jsonplaceholder.typicode.com
- In the Entities field, add JSON code which provides makeen transform the details of entities as well as the endpoints which the service provides. For the sake of this example, use the code snippet below.
[{ "Entity": { "Name": "Todos", "Schema": { "Fields": [{ "Name": "Todos", "Type": "Object" }] }, "Services": [{ "ServiceName": "GetTodos", "Parameters": [{ "Name": "Method", "DefaultValue": "todos", "Type": "String" }, { "Name": "MethodType", "DefaultValue": "GET", "Type": "String" } ], "Result": { "Name": "Todos", "Type": "JObject" } }] } }]
- Click on the Test Connection button. If the test succeeds, click on Save to create the connector.
Code Breakdown
Based on the snippet above -
- There is only one entity, "Todos".
- "Schema" defines the fields of this entity.
- In Fields, there is only one field of the type "Object". This means a generic object will be used for each record.
"Parameters": [{ "Name": "Method", "DefaultValue": "todos", "Type": "String" }, { "Name": "MethodType", "DefaultValue": "GET", "Type": "String" }]
- The aforementioned part of the code defines the services which apply operations on this entity. There is only one service in this case, "GetTodos".
- "Parameters" defines the name of the service endpoint ("todos") and HttpMethod ("GET").
- Use slash( / ) in the endpoint name when the endpoint is a path rather than not a simple name. For instance, you can use ("todos/1") here.
- "Result" defines the returning object and its type. Use "JObject" for Json and "XDocument" for XML. Though these two types are used to define the type of returned object (Json, XML), this is inferred automatically in the code while calling service.
Step 2 - Configure Entities
With this step, entity data will be downloaded in the mobile app when launched. Here is what you need to do:
- Click on the configure icon for the REST connector you created.
- Click on the Entities tab (shown below). You should be able to see the entity Todos.
- Click on '+' icon associated with the entity. Click on the Info tab on the right, and make sure that the entity is set to"downloadable".
- Finally, click the Save Entity or Save All Entities button based on the number of entities you wish to apply changes to.
Step 3 - Start Using the REST Connector
You can now fetch data from entities in RESTful systems. Here is one example where the title of todos data is fetched in a Picker control.
Watch How It's Done
This video tutorial explains how to connect Mobile Forms to SOAP or REST Web Services.
Need more help? Contact us at support@makeen.io