Jump to content


Photo

Gravity Forms Integration Solution [SOLVED AND AVAILABLE]

gravity forms integration restAPI

  • Please log in to reply
14 replies to this topic

#1 eugeneb

eugeneb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCenturion, south Africa

Posted 28 September 2018 - 08:38 AM

To anyone interested.

 

I have long since been looking for an elegant solution for integrating another more flexible form-tool for WordPress with X2CRM. Some other guys tried developing WordPress plugins but I was never able to work with that.

 

I extensively started using Gravity Forms (GF) on all my and customer sites due to its incredible flexibility and ease of use. Using GF I tend to always ask the contact details and then my custom field, which I don't always need in X2, but would like to capture the contact and maybe do some cool automation stuff. I tent to prefer not to hard code, to avoid custom dependency.

 

I found a great and elegant solution for this and it works great. 

 

Using Gravity forms there is a little known GF plugin called SEND TO THIRD PARTY. This simplifies the RestAPI POST call by giving you a simple plkug and play type page with additional GF settings. Install the plugin in WordPress and in Gravity forms you can easily set it up to post to X2CRM by completing some key fields.

 

I initially had a problem accessing my API which I was able to solve on this forum thread: http://community.x2c...ut-not-getting/

 

So now I can use GF fully and send the contact and fields info over to X2CRM. Adding tags directly, making lists and using X2Flow Record Create triggers do even more with the new record comming in from GF.

 

I hope this helps someone else that also wants to use Gravity Forms for more advanced form features on your website.



#2 Attila

Attila

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts
  • LocationJohannesburg, South Africa

Posted 01 October 2018 - 01:53 AM

Nice one Eugene  thank you 


Never allow waiting to become a habit. Live your dreams & take risks. Life is happening NOW !


#3 Ward@HRTechAdvisor.com

Ward@HRTechAdvisor.com

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 01 February 2019 - 10:29 AM

Thanks for sharing Eugene!

Does Gravity Forms also let you pull data from X2 via API or only push?

If only push, can you recommend a form tool that goes both ways?



#4 eugeneb

eugeneb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCenturion, south Africa

Posted 03 February 2019 - 11:07 PM

Hi Ward,

 

both X2 and Gravity forms have Rest API's so you can do any integration either direction with both from a programmatic point of view.

 

However, the Wordpress Gravity plugin I use to make the integration just quicker is one directional in my usecase. Thus pushing from Gravity to X2. I haven't investigated the more complex application for that plugin. It does have GET functions so maybe it can pull info from X2.



#5 alt_f4

alt_f4

    Advanced Member

  • Premium Members
  • PipPipPip
  • 367 posts
  • LocationGermany

Posted 25 February 2019 - 04:35 AM

Hi Eugene

 

I´m just testing "your" solution. Can you post the settings and/or an example screenshot og the WP-backend with the settings used? Seems it won´t work on my site :-(

 

My settings:

 

general

a.) your ".htaccess"

WP backend

b.) API connection: method. POST

c.) Auth: basic (username/password with API credentiols)

d.) headers: nothing

e.) API parameters: Format: default

f.) MAP: email -> E-Mail

 

Should work, hmmm? Any tipps?

Screen: https://www.bilder-u...098178.png.html

 

 

Regards!



#6 chad1964

chad1964

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 25 February 2019 - 12:24 PM

I have the same settings as alt_f4 above and with no luck either - anyone willing to shed some light on this I would be grateful - ty



#7 eugeneb

eugeneb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCenturion, south Africa

Posted 26 February 2019 - 12:17 AM

Hi guys,

 

sorry for the late reply. Lets see if we can fix this.

 

From what I can see I still have some things different which will make a difference. You need to create some fields in Gravity with default values. These values you then need to put into the relevant fields of the 3rd party plugin. They are separate from the user fields you need the client to complete.

 

GF Fields: I usually separate and Group my fields on Gravity Forms to know what they do. I have attached screenshots (Shots 1-3) to show you. First I group SETTING type fields and then any other fix values I want to pass through I put in FIELDS group. All these fields are on the Gravity form with default values, but hidden from the end-user. By doing this you can use these values in your 3rd party app. You can see the default values I have in the fields in grey.

 

3RD PARTY PLUGIN: You will need to setup like I have in my screenshot. Especially the Content-type. If setup in the field, then you can use this in the header also. The final screenshot shows how I mapped all fields and Header setting.

 

If your .htaccess file is setup right, this should pass through. Remember to include the Visibility and AssignTo fields as compulsory seeing as just creating a user via the API will leave these field nulled thus your contact wont show in X2 front-end even if it was created in the X2 DB. By setting the Visibility and Assignto values your contact will show.

 

Let me know if you guys get it right.

Attached Files



#8 alt_f4

alt_f4

    Advanced Member

  • Premium Members
  • PipPipPip
  • 367 posts
  • LocationGermany

Posted 26 February 2019 - 02:54 AM

Hi Eugene

 

1000  :)

 

Works like a warm summer breeze...

 

 

Regards!



#9 robert.keir

robert.keir

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts

Posted 26 April 2019 - 01:48 AM

Hi Eugene,

 

This is great! We have a separate application that does not use GF. Do you perhaps have the PHP code for what you did in your example above?

 

Nice to see you the other day!

 

Thanks,

Rob



#10 robert.keir

robert.keir

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts

Posted 26 April 2019 - 05:37 AM

Hi All,

 

We are trying to use restful API to create a new opportunity using version 7.0 of x2crm.

 

Can someone comment on our PHP code below (I've changed the URL Address):

 

<?php
 
$request = new HttpRequest();
$request->setMethod(HTTP_METH_POST);
 
$request->setQueryData(array(
  'assignedTo' => 'Anyone',
  'c_Assigned_Dealer' => '1',
  'Name' => '1',
  'updatedBy' => 'Anyone',
  'visibility' => '1'
));
 
$request->setHeaders(array(
  'Connection' => 'keep-alive',
  'content-length' => '',
  'accept-encoding' => 'gzip, deflate',
  'cookie' => 'PHPSESSID=v6ni4nvrfs1p5bma80qcs6v2s3',
  'Host' => 'www.xxxx.co.za',
  'Accept' => '*/*',
  'User-Agent' => 'PostmanRuntime/7.11.0',
  'Authorization' => 'Basic YWRtaW46VG0zQlU5d1Fvd3pWVjd4UTZ3NkI0R2p6N3N4WWRsdUw=',
  'Content-Type' => 'application/json'
));
 
try {
  $response = $request->send();
 
  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
 
We keep getting the following error:
 
{
    "httpHeaders": {
        "Content-Type": "application/json; charset=utf-8"
    },
    "reqHeaders": {
        "Content-Length": "0",
        "Content-Type": "application/json",
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Authorization": "Basic YWRtaW46VG0zQlU5d1Fvd3pWVjd4UTZ3NkI0R2p6N3N4WWRsdUw=",
        "Connection": "keep-alive",
        "Cookie": "PHPSESSID=v6ni4nvrfs1p5bma80qcs6v2s3",
        "Host": "www.xxxxx.co.za",
        "User-Agent": "PostmanRuntime/7.11.0"
    },
    "message": "Missing or malformed data sent to server.",
    "error": true,
    "status": 400
}
 
Any help would be appreciated. 
 
Thank you.


#11 eugeneb

eugeneb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCenturion, south Africa

Posted 29 April 2019 - 05:42 AM

Hi Rob,

 

nice to see you guys the other day. I don't have PHP code for our method as I am using a plugin.

 

What are you using to check you code and info sent to the API? We used Postman and worked it through until it all worked.

 

We also got Error 400's and gradually sorted the fields in the plugin. Without PHP.

 

Also check your htaccess. file to make sure the info is passing through to X2. Thanks unfortunately all I can help with.

 

Keep me posted.



#12 robert.keir

robert.keir

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts

Posted 29 April 2019 - 05:57 AM

Hi Eugene,

 

We use postman - works nicely with Get request. When we want to Put - error 400. We check that all mandatory fields are correct and have values. 

 

Would it be PHP not passing the request through from another location other than the server it is located on? I'll email X2crm and see if there is anything they can advise on. 

 

Do you know what setting would possibly be the culprit here? Deny-all or something like that?

 

Will keep you posted. 



#13 eugeneb

eugeneb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCenturion, south Africa

Posted 29 April 2019 - 06:01 AM

Our problem was also security between servers. Not sure if you saw my thread about the .htaccess file.

 

After hours of searching and trialing it turned out the htaccess file was the culprit. Who knows, maybe its the same for yours.

 

http://community.x2c...ut-not-getting/

 

:)



#14 robert.keir

robert.keir

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts

Posted 29 April 2019 - 06:08 AM

Thank Eugene - I"m going to have a look and give feedback.



#15 robert.keir

robert.keir

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts

Posted 02 May 2019 - 05:23 AM

It turned out that it had nothing to do with .htaccess for us. 

 

Here is the sample code that I found on the community forum (http://community.x2c...-to-server-400/)  which I adapted for it to work from any server to our server. 

 

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

//Assign values
$firstName = $name;
$lastName = "$lastname";
etc...
 
//create array
$username = "USER";
$password = "API_USER_KEY";
$contact = array(
      "firstName" => $firstName,
      "lastName" => $lastName,
      "email" => $email,
      "leadSource" => $leadSource,
      "city" => $city,
      "c_Quoted_Brand" => $c_Quoted_Brand,
      "c_Instant_Quote_Status" => $c_Instant_Quote_Status,
      "c_Quote_no" => $c_Quote_no,
      "c_Unit" => $c_Unit,
      "phone" => $phone,
      "state" => $state,
      "description" => $notes,
      "assignedTo" => "Anyone",
      "updatedBy" => "Anyone",
      "visibility" => 1
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.SITE.co.z...api2/X2Leads");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8;")); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); 
$data = json_encode ($contact);
curl_setopt($ch, CURLOPT_POST, $data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
 
//Actual Call to Server
$server_output = curl_exec ($ch);
=====================================================
 
Works like a charm. Just need to update the username, API key, variables in the array and then the URL for the module.
 
I saw the last time the API document was updated was on the 21st Dec 2015. Is there perhaps a newer version?
 
Does the API allow for PDF document uploads?
 
Thanks,
Rob 






Also tagged with one or more of these keywords: gravity forms, integration, restAPI

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users