In the previous tutorial we've gone over all the basics of setting up a POST web service block in your AppMachine app. This tutorial will cover creating a GET web service block to retrieve the data that was submitted with the POST web service. 


 

Prerequisites 

  • Part 1 of this tutorial series need to be completed, or you already have a POST web service in your app.
  • Your datastore needs to contain some data, either real data or test data from your test runs. 


After making sure your app meets these requirements, we can continue. 

 


Section I - Add the GET web service block


  1. Add a Web service block by clicking the red "+ Block" button and selecting it from the Pro blocks tab.


  2. Select AppMachine as provider.


  3. Select the GET option from the list of predefined web service types.


  4. On the next screen we will determine the number of results the GET web service will retrieve and from which datastore the data is taken. 
    We've chosen for 250 records and filled in the name "reports" as that's the name of the datastore used in this tutorial.

    !!! Note: You can ignore the dropdown that pops up when you select a field.


  5. After continuing to the next screen we'll set up the mapping of the GET web service. Select the array with the data from your test entries. 
    There is no need to change the field types, this can be done at a later time if needed.


  6. On the next screen you'll name your block and finish it. 


 


Section II - Adjusting the layout of your GET web service block


A GET web service block consists out of two separate blocks. After following the steps shown above you should have ended up with a block "All Reports" (or whatever title you've chosen) and a block called "Info". 


The "All Reports" block is your List block, while the "Info" block is the details Screen block. As you probably already expected, the List block displays the list of reports that were submitted by app users and the details Screen block shows the details of an item after you've selected one from the List. 


In this section we'll quickly glance over changing the layout of your List and details Screen blocks. 


  1. Open the "All Reports" block. You'll see that the default layout shows the "Title" component. 
  2. Add any component you want from the list of data items on the left of the Layout editor: 
    It's a simple drag and drop system. Adding more components will change the way the list looks. 
  3. Do the same thing for the "Info" block that is nested below the "All Reports" block. 



Section III - Placing the GET web service block 


This is a simple one. You'll have to decide whether your GET web service block will be available for all app users or just a select group. If all users should be able to see the submitted items, you can leave the GET web service block as is, but if you want it locked off for certain users it would be a good idea to place another Lock block in your app. You can refer to Part 1 of this tutorial to see how you can implement a Lock block in your app. 


For the sake of keeping the tutorial simple we'll build the setup to let users see and edit their own submitted reports. In a follow-up tutorial we'll guide you through the process of creating a setup for admins only. 


For now you can position your new "All Reports" block below the "Submit Report" block to make use of the same Lock block you already created.


 


Done. For now.. 


This part of the tutorial only covered the basics. In the following parts we'll dive a bit deeper into some of the more advanced features of the List block. Part 3 regarding PUT web services (updating data) can be found here


If you have any feedback about this tutorial, or questions, please let us know by sending an email to support@appmachine.com.