Handling form submission via REST API

26 views
Skip to first unread message

Jeremy Prowse

unread,
Jun 24, 2024, 7:35:03 PM6/24/24
to Zengine Development
Hey there,

We are scoping an integration where a number of custom forms will be sending data to Zengine. The forms will be created in Zengine ahead of time and the relevant fields mapped to our rest request to send the data through.

I can't seem to find an example outlining on how to structure this request within the documentation so am wanting to know if we are on the right track with a request structure similar to that specified below (in PHP):

Another question is the formatting of multiselect fields such as checkboxes, are these expected to be sent as an array, string, csl, or some other format. Any guidance on this front would be greatly appreciated.

==========================================================

<?php

$client = new GuzzleHttp\Client();
$formID = '1234567890'

$res = $client->request(
  'POST',
  'https://api.zenginehq.com/forms/'.$formID.'/records.json', [
  'auth' => 'access_token',
  'body' => [
    'field123' => 'John', // string
    'field456' => 'jo...@example.com', // email
    'field789' => '+6421987654321' // phone number
    'field987' => [
      'option1',
      'option3',
      'option5'
    ], // checkboxes (are these to be an array, string, csl, ...?)
    ...
  ]
]);

$status = $res->getStatusCode();
$res_body = $res->getBody();

==========================================================

Many thanks.

Wes

unread,
Jun 28, 2024, 10:18:24 AM6/28/24
to Zengine Development
You should pass the access token in the Authorization header:

headers: {
  Authorization: Bearer {token}
}

You should submit JSON to the API by setting the content-type to application/json and sending a JSON payload as the body. The JSON fields will be similar to what you have here with the field ids.

I would recommend using the web based app to save some records and look at the network requests the browser makes if you want to see what type of data and formats are being used by your particular form fields.
Reply all
Reply to author
Forward
0 new messages