A Simple RESTful Service: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
m
Link
m (Typo)
m (Link)
Line 591: Line 591:
If you then compile and run the WebApp (F5), and change the URL in the web browser (Firefox is best for this, as it displays the returned JSON in the nicest format), replacing "Index.html" with "customerAPI" (the psPath setting in the code) you should see the output produced by the "ApiRoot" procedure, which will (at this point) have a single ''collection'': "customers". Clicking (in Firefox, at least) on the "href" value for that should then display a list of customers, each of which should in turn have an "href" element, clicking on which will take you to the details for that customer.
If you then compile and run the WebApp (F5), and change the URL in the web browser (Firefox is best for this, as it displays the returned JSON in the nicest format), replacing "Index.html" with "customerAPI" (the psPath setting in the code) you should see the output produced by the "ApiRoot" procedure, which will (at this point) have a single ''collection'': "customers". Clicking (in Firefox, at least) on the "href" value for that should then display a list of customers, each of which should in turn have an "href" element, clicking on which will take you to the details for that customer.


To do more than simply display (i.e. GET) data, you will have to use a tool such as [https://www.getpostman.com/ Postman] (click the "Get Started" button, then the "Download" button, selecting the version - 32 or 64 bit - as appropriate for your machine, saving and then running the downloaded file) or the RESTTester tool detailed in the [#Consuming_RESTful_Services|Consuming RESTful services section above.
To do more than simply display (i.e. GET) data, you will have to use a tool such as [https://www.getpostman.com/ Postman] (click the "Get Started" button, then the "Download" button, selecting the version - 32 or 64 bit - as appropriate for your machine, saving and then running the downloaded file) or the RESTTester tool detailed in the [[Consuming RESTful Services in DataFlex]] article.


To create new customer rows you will need to use POST to the customers ''collection'' (e.g.: .../customerAPI/customers), passing the required JSON in the request body (in Postman go to the request "Body" tab and select "raw" just below that). At a minimum that should be something like:
To create new customer rows you will need to use POST to the customers ''collection'' (e.g.: .../customerAPI/customers), passing the required JSON in the request body (in Postman go to the request "Body" tab and select "raw" just below that). At a minimum that should be something like:

Navigation menu