Enable Try it out

Consumers can exercise endpoints from DeveloperHub without leaving the site when Services have the appropriate CORS and one or more supported authentication rules. The supported authentication rules include Basic Auth rule, JWT Validator rule, and API Key Authenticator rule.

The general steps to enable the Try it out feature include:

  1. Create a policy with a CORS Restriction rule and one or more of the supported authentication rules.
  2. Apply the policy to the Service or endpoint.
  3. Publish the Service to DeveloperHub with Public visibility.

For the Hello World Service, we'll create a Policy with CORS Restriction and Basic Auth authentication rules.

Create the Policy

First create the Policy:

  1. From the left navigation panel, select Policy catalog.
  2. Click New Policy. The New policy panel opens:

    New policy panel

  3. Click New Policy and change the Policy name to Try-it-out

Next add the CORS Restriction rule:

  1. Click Validate. The Validate panel opens.
  2. Click CORS Restriction.
  3. Leave the When this policy should be applied field empty.
  4. To the right of the Access Control Allow Origins section, click the plus sign.
  5. Enter the base URL for your SnapLogic environment, for example: https://elastic.snaplogic.com or https://emea.snaplogic.com. Enter it without a trailing /.
  6. To the right of the Access Control Request Headers section, click the plus sign.
  7. In the new field, enter Authorization.
  8. Click the plus sign next to Access Control Request Headers again.
  9. In the new field, enter content-type.
  10. Scroll down and enable Access Control Allow Credentials.
  11. Click Validate & save.

Finally, add the Basic Auth rule and save the Policy:

  1. Click Authenticate.
  2. Select Basic Authentication.
    Important: Snaplexes must be running on version 4.42 or later to use this rule.
  3. Leave the When this policy should be applied field empty.
  4. Click Validate & save.
  5. Click Save to save the Policy.
  6. Select the project where you created the Hello World Service and click Save.

Apply the Policy to the Service and Publish

For this example, we'll apply the Try-it-out Policy to the Service.

  1. From the left navigation pane, click Service catalog.
  2. Navigate to the Hello World Service version and open it.
  3. Change the Service status to Testing.
  4. Click the Policies tab.
  5. Next to Service Policies, click the plus icon.
  6. Navigate to the project where you saved the Policy and select it.

Because we already applied a Basic Auth rule to the endpoint, the Service Policy shows that it has been overridden at the endpoint level:


Service Policy with endpoint override

With the Hello World Service open, click Testing and select the Public published status.

View the Service in DeveloperHub

To view the Service in DeveloperHub:

  1. From the left navigation panel, select Site Manager. Site Manager opens.
  2. Click View Site.
  3. Open the Services catalog page. In the following example, it was renamed to API catalog:
    DeveloperHub header example

  4. Click the Hello World Service to view its details.
  5. Click the get-message endpoint to expand it. The card now contains Authorize and Try it out buttons:
    Authorize and Try it out buttons.

  6. Click Authorize.
  7. Enter your SnapLogic user name and password and click Authorize.
    Authorize dialog.

  8. Click the X to dismiss the Authorize dialog.
  9. Click Try it out.
  10. Click Execute.
  11. The response displays:
    Try it out response.

Troubleshooting

If you encounter an error, check the following:

  • Did you enter the correct username and password and authorize them so that they show as asterisks?
  • Did you configure the CORS and Basic Auth rules correctly? For example, the Access Control Allow Origin in the CORS Restriction rule shouldn't end with a forward slash.

To make changes to a rule in the Policy:

  1. Unpublish the Service.
  2. Make your changes.
  3. Save the rule and the Policy.
  4. Republish the Service.
  5. Reload the DeveloperHub page and try again.