0

I have a running workflow which I would like to post fields to via an API call (see below):

 $ret = invokeFlowgear(
   "https://domain.flowgear.io/salesbooks",
   "username",
   "password",
  30,
  array(
     'name' => 'Introduction to Data integration with Flowgear',
     'isbn' => 'X-XXX-XXXX',
     'qis' => 0,
     'price' => 250.99,
     'author_id' => 3  
   )
);

Eventually this call should result into the workflow inserting the data onto the table and returning a success message.

What do I need to have this achieved with a workflow via an API?

scruffycoder86
  • 527
  • 1
  • 5
  • 24

1 Answers1

1

You need to accept the raw HTTP POST body into the Workflow. To do that, set an appropriate URL ("/salesbooks/") in the workflow detail pane and set the method to POST.

Then drop in a Variable Bar and add the special property FgRequestBody. Optionally also add FgRequestContentType so you can inspect the content type of the message being received.

Create an HTTP POST to that Workflow and you can see what's coming through to the FgRequestBody property (it will show in the Start entry in the activity logs).

If you need to convert between JSON and XML, using JSON Convert.

Daniel
  • 506
  • 2
  • 5
  • 1
    Flowgear treats a path ending with a slash and one without as a different URI. For example if you have the URL https://customdomain.flowgear.io/thing/ when you type this in a browser, ensure you have included the trailing slash – Daniel Jan 04 '16 at 07:41
  • Could be the HTTP method doesn't match - if you open the URL in a browser, you're performing a GET so you'd need to set the method to GET. Or, if you're using the sample PHP code at http://developers.flowgear.net/kb/PHP_API_Example (which it looks like you are), then that expects you to have set the method to POST. – Daniel Jan 04 '16 at 11:54