scruffycoder86
scruffycoder86

Reputation: 549

How to configure a workflow to reurn a json output via API Call

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?

Upvotes: 0

Views: 156

Answers (1)

Daniel
Daniel

Reputation: 504

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.

Upvotes: 1

Related Questions