On this page

Examples and troubleshooting

A complete workflow

Import a collection, connect, find an endpoint, run it as a table, then keep the result:

IMPORT API BRUNO "C:\bruno\my-api.yml" MYAPI;
CONNECT API MYAPI:Development;
SHOW ENDPOINTS MATCH user;
RUN /users TABLE;
DUMP API RESULT TO REPORT.USERS AS XLSX;
DISCONNECT API;

Each step is described on its own page: API sources and configuration, Running API requests and Working with API results.

SQL and API together

A database connection and an API session context can be active at the same time, and BroadSQL keeps running ordinary SQL against the database connection throughout; connecting to an API never closes or replaces it:

$CDF> CONNECT API DESK:PROD;

API DESK connected using environment PROD.

$CDF [API DESK:PROD]> RUN /api/rest/emails/v1/ping?key=DESK;

API: Desk Definition API
Environment: PROD
Endpoint: GET Check email service

GET https://desk.example.com/api/rest/emails/v1/ping?key=DESK

HTTP 200
Duration: 143 ms

OK

$CDF [API DESK:PROD]> SELECT COUNT(*) FROM CUSTOMER;

COUNT(*)
--------
1241

$CDF [API DESK:PROD]> DUMP API RESULT TO PING_RESULT AS CSV;

1 row(s) exported to PING_RESULT.csv.

$CDF [API DESK:PROD]> DISCONNECT API;

$CDF>

The same coexistence holds for a write endpoint: the database connection is no more affected by a POST/PATCH/DELETE than by a GET:

$CUSTOMERS_DB> CONNECT API CRM:TEST;

API CRM connected using environment TEST.

$CUSTOMERS_DB [API CRM:TEST]> RUN POST /customers;

API: CRM Service
Environment: TEST
Endpoint: POST Create Customer

POST https://crm-test.example.com/customers

HTTP 201
Duration: 118 ms

id     : 501
status : created

$CUSTOMERS_DB [API CRM:TEST]> DUMP API RESULT TO api_customer.CUSTOMERS AS H2;

1 row(s) exported to api_customer.CUSTOMERS (table dropped and recreated).

$CUSTOMERS_DB [API CRM:TEST]> SELECT * FROM api_customer.CUSTOMERS;

|---|-------|
|ID |STATUS |
|---|-------|
|501|created|
|---|-------|

$CUSTOMERS_DB [API CRM:TEST]> DISCONNECT API;

$CUSTOMERS_DB>

CUSTOMERS_DB, the SQL connection, is exactly as it was before CONNECT API ran; only the API session context changed.

Troubleshooting

MessageWhat it meansSee
No API is connected. Use CONNECT API <api>:<environment>; before RUN.RUN needs an API session.Running an endpoint (RUN)
No endpoint matches: ...No active endpoint of the connected API has this method and path shape, or the endpoint is inactive.Executing an inactive API, endpoint, or environment
Unable to resolve variable: ...A ${name} used by an enabled part of the request has no value.Variables
Execution refused. Method OPTIONS is not enabled for execution in this release.The method, or a form-urlencoded/multipart-form body, cannot be executed yet.Executing an unsupported method or body
API 'MYAPI' is inactive. ...The API or the environment was deactivated in CONFIG API.Executing an inactive API, endpoint, or environment
DUMP API RESULT: no API execution result held in memory. Run RUN first.The last call did not succeed, or none was made.Exporting API results
Running the endpoint is refused, naming its authentication typeThe endpoint uses an authentication type this release cannot execute (Digest, NTLM, OAuth1, AWS Signature, OAuth2 Authorization Code or Password).Authentication