scruffycoder86
scruffycoder86

Reputation: 549

How to invoke a FLOWGEAR workflow via an API using a POST-SELECT

I have a workflow that selects a list of books based on projected sales value of R 5000.00 where author is "Siko Luyanda". When testing the query I created it returns me 2 records. My workflow returns the same recordsas well, happy.

I have used the Formatter node to create the sql query that is passed to my ODBC node since am querying MySQl Server. In the workflow content pane the HTTP method of the endppoint is set to GET. Invoking my workflow with php via an API call works fine:

 $results = invokeFlowgear("https://domain.flowgear.io/authorbooksaleslist", , "login", "pwd", 30,array());

The resulting output is what I get from the workflow console and the database itself I am happy.

However, the minute I change my endpoint to use POST my query fails. Take for example a HTML form that uses a POST method to hide the fields being posted.

At this point I get an exception which says, "The service is not available", if I set my endpoint to post as a method meaning I cannot do a "POST-SELECT" query via the workflow and API call. Below is how I invoke the workflow with variable bar variables as post fields.

$results = invokeFlowgear("https://domain.flowgear.io/authorbooksaleslist", "login", "pwd", 30,
       array(
        'salesValue' => 5000.00,
        'authorId' => 3
     ));

The values in the array are what I want to pass inside the Formatter node before the results are sent to the ODBC node. Eventually I should get my results listed back.

Is it ever possible to have an HTTP POSt endpoint, pass values via an API for an sql query to be run on the database and serve the results whichever way I choose?

The idea is that at some stage we would want to sensitive information even when we just want to select info from th edatabase.

Upvotes: 0

Views: 203

Answers (1)

Skillie
Skillie

Reputation: 151

Your HTTP Method in the workflow must be set to POST if you are invoking the endpoint with a POST method.

Flowgear will only populate the variables in the Variable Bar if the request body is a one tier JSON payload which is a simple key-value pair.

If you are using another form of post, you can access the post body through the special Variable Bar property FgRequestBody.

Hope this helps.

Upvotes: 0

Related Questions