// Module included in the following assemblies:
// as_trigger-integrations-with-api-calls.adoc

[id='try-api-provider-quickstart_{context}']
= Testing the example API provider quickstart integration

When the {prodname} *TaskAPI* quickstart integration is running, you can
invoke `curl` utility commands that send HTTP requests to the Task API service.
How you specify the HTTP request determines the flow that the call
triggers.  

.Prerequisites

* {prodname} indicates that the *TaskAPI* integration is *Running*. 
* If your {prodname} environment is running on OCP, 
{prodname} is not configured to expose APIs to 3scale or
you disabled discovery for the *TaskAPI* integration. 

.Procedure

. In {prodname}, in the left navigation panel, click *Integrations*. 
. In the *TaskAPI* integration entry, click *View* to display the
integration's summary. 
. Copy the integration's external URL. 
. In a terminal, invoke a command such as the following to assign the
integration's external URL to the `externalURL` environment variable.
Be sure to replace the URL in this sample command with the URL that you copied.
+
----
export externalURL="https://i-task-api-proj319352.6a63.fuse-ignite.openshiftapps.com/api"
----

. Invoke a `curl` command that triggers execution of the 
flow for the *Create new task* operation: 
+
----
curl -k --header "Content-Type: application/json" --request POST --data '{ "task":"my new task!"}' $externalURL/todo 
----
+
* `-k` allows `curl` to proceed and operate even for server connections 
that are otherwise considered insecure.
* `--header` indicates that the command is sending JSON format data.
* `--request` specifies the HTTP `POST` command, which stores data.
* `--data` specifies the JSON format content to be stored. In this example the  
content is `{ "task":"my new task!"}`.
* `$externalURL/todo` is the URL to invoke. 

+
This command sends an HTTP `POST` request to the Task API service, which
triggers execution of the *Create new task* operation's flow. Flow
execution adds a new task to the sample database and returns a message
such as the following to indicate what it did:

+
----
{"completed":false,"id":1,"task":"my new task!"}
----

. Invoke a `curl` command that triggers execution of the 
flow for the *Fetch task* by ID operation:
+
----
curl -k $externalURL/todo/1 
----
+
To obtain a task, the `curl` command needs to specify only the URL. The
HTTP `GET` command is the default request. The last part of the URL
specifies the ID of the task to get. 

. Invoke a `curl` command that triggers execution of the 
flow for the *Delete task* for ID operation:
+
----
curl -k -X DELETE $externalURL/todo/1
----
+
This command invokes the HTTP `DELETE` command with the same URL as the
command that obtained a task by its ID. 
