Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

This guide will walk you through creating an API file and a basic Get REST API endpoint that will return the a Hello World message.

Open the workspace 

(If you haven't created an example workspace, create a workspace called papihello. See Using Workspaces

Open the example workspace by pointing your browser to the URL:

http://[HOST]:[PORT]/ide/papihello

Where host is the server you installed Profound.js on and port is the port number Profound.js is running on. If the installation is on your PC or Mac computer, use localhost.

OR open the workspace from the ide with the Open button and then select the example workspace:


Create API file

Create a new API json file by clicking the New button and selecting API file. The file will be opened and the Canvas, Parameters, API Routes, and Properties panel will be initialized.

                   

Set Properties

On the left hand lower panel select the General Info tab and fill on the following values

  • Name: hello
  • Summary: hello world example
  • HTTP Method: get

  • HTTP Path: /helloworld

  • Category, Sub Category, Tag, and Description all help improve documentation and organization. 

Output Parameters

In the lower center panel select the Output Parameters tab. 

Click the green plus button to add a new parameter. This will open the API Parameter dialog.

Enter Response for the name and leave the Data type set to string. Adding an example and description helps the auto-generated documentation be more complete. 

Click OK to add the parameter.

Save

Save your API file by clicking the Save button in the menu ribbon. The first time you use save you will be presented a save dialog with the File Name defaulting to Unnamed.api.json. You should change the Unnamed portion to an appropriate file name, like helloworld.api.json in this case. Click Save.



Add Logic

It is best to add properties and parameters and then save before starting on logic steps because the parameters will appear as options when building the logic steps.

Profound API uses Low Code steps to build the logic of the API. In this example we have one step to set the output to the "Hello World" message.

Click on Add Step... in the canvas.

The step builder dialog will open. At the top type a description for the step then in the What would you like to do? drop down scroll down and click on Program Data. From the Program Data options click on Set API Output

The dialog will update to allow you to specify the value for the response parameter. For this example we will return a static string value so enter the value 'Hello World' for the parameter. Then click OK.

Save

Save the changes

Test

On the lower right panel switch to the Test tab. If the API endpoint expected parameters there would be options to enter them at the top of the Test panel.

For this example, there are no parameters so just click Execute to test the endpoint.

After running the test the panel will update with several responses.

  1. Curl - This box will present the Curl command that can be run to consume the REST endpoint
  2. Request URL - the URL of the request. In the case of a GET request this URL can be copied and pasted into the Address bar of your browser to test the endpoint directly from the browser.
  3. Server response - The server response section includes the HTTP code returned as well as the Response body and headers. 
  4. Response body - In this case the response body includes our parameter with the Hello World message.
  5. Response headers - includes all of the headers returned from the server  
  6. The Response section shows what response types should be expected including any default values that were defined in the parameters.






  • No labels