Prerequisites

This document is intended for an API professional or a person with extensive API coding knowledge.  The below assumes you have extensive knowledge in working with API's.

It is not designed as a step-by-step FAQ on how to work with API's, Zapier or any programming language.  The support team is unable to show you how to work with Zapier or any programming languages.  It is designed as an example of linking Zapier to Gensolve for an API professional.

You should have knowledge on how to make API requests from Gensolve.  API professionals please refer to How to Get Started using GPM's API

Solution

You can use our API documentation with Zapier to get data from GPM.Please refer to the following example which demonstrates how to create a flow between Zapier and GPM to get a list of new clients in an Excel spreadsheet.

Create an account

Authenticate your credentials

Get all vendors

Get all clients created yesterday

Create an account

  1. Go to https://zapier.com/ >> Fill the Work Email, First Name and Last Name
  2. Click on Get Started Free
  3. Click on Make a Zap
  4. Click on to rename your Zap and  enter Get new Client Appointments with Gensolve's API

Set up the trigger

  1. First you need to schedule how often do you want to automatically create the spreadsheet, click on Schedule
  2. Select the Trigger Event and click on Continue
  3. Select the Trigger On Weekends and Time Of Day.
  4. Click on time zone settings
  5. Once the Profile is opened, select your Timezone.
  6. Click on Save Changes

  7. Return to the previous tab and click on Test trigger
  8. Click on Continue

Authenticate your credentials

  1. Click on to create the second step
  2. Enter Code by Zapier on the search bar
  3. Click on Code by Zapier
  4. Click on >> Click on Rename step >> Enter Authenticate to Gensolve's API
  5. Select the Action Event: Run Python and Click on Continue
  6. Add 4 inputs: OrganisationName, Password, SecretKey, UserName
  7. Copy and paste the following text in the Code text box

import requests

import json

url = "https://nzapi.gensolve.com/api/token"

payload = json.dumps({

    "organisationName": input_data.get("OrganisationName"),

    "password": input_data.get("Password"),

    "secretKey": input_data.get("SecretKey"),

    "userName": input_data.get("UserName")

})

headers = {

    'Content-Type': 'application/json'

}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

 

  1. Click On Continue

 


Note: You need a user set with Api access. For more information please refer to Allowed Access Roles.


Note: The SecretKey can be taken from the API Configuration, for more information please refer to Allowed System Users.

  1. Click on Test & Continue and be sure the Log is correctly retrieved as follows

Get vendor

  1. Click on to create a new step
  2. Click on >> Click on Rename step >> Enter Get Vendor
  3. Select the Action Event: Run Python and Click on Continue
  4. Add one Input Data AuthToken and insert the 2. Runtime Meta Logs
  5. Enter the following Code:

Note: IMPORTANT:  Ensure you enter the name of your Gensolve Vendor where the below code is highlighted in yellow as INSERT NAME OF YOUR GENSOLVE VENDOR

import requests

import json

url = "https://nzapi.gensolve.com/vendors/get"

 

payload={}

headers = {

  'Authorization': input_data.get("AuthToken")

}

response = requests.request("GET", url, headers=headers, data=payload)

vendors = json.loads(reponse.text)

vendorsData = vendors.get("Data")

for obj in vendorsData:

  if obj.get("Name") == "INSERT NAME OF YOUR GENSOLVE VENDOR ":

      print(int(obj.get("Id")))

Print (response.txt)

  1. Click on Continue

 

  1. Click on Test & Continue and be sure the Vendor is correctly retrieved as follows

Get all clients created yesterday

  1. Click on>> Click on Rename step >> Enter Get Clients Created
  2. Select the Action Event: Run Python and Click on Continue
  3. Add the following inputs:
    AuthToken: 2. Runtime Meta Logs
    VendorId: 3. Runtime Meta Logs
  4. Enter the following Code

    from datetime import timedelta

    from datetime import date

    import requests

    import json

    vendorId = input_data.get("VendorId")

    dateTo = date.today()

    dateFrom = dateTo - timedelta(days=1)

    url = "https://nzapi.gensolve.com/clients/matching_clients?VendorId=" + vendorId + "&DateFrom=" +

    dateFrom.strftime("%Y-%m-%d %H:%M:%S") + "&DateTo=" + dateTo.strftime("%Y-%m-%d %H:%M:%S")

    payload={}

    headers = {

      'Authorization': input_data.get("AuthToken")

    }

    response = requests.request("GET", url, headers=headers, data=payload)

    if response.status+code ==200:

       clients = json.loads(response.text)

       clientsData = clients.get("Data")

       for obj in clientsData:

         print(obj.get("FirstName"))

    elif response.status_code == 400:

       print(response.text)

    elif response.status_code == 204:

       print('No clients found')

  5. Click on Continue
  1. Push data to Active Campaign