Jump to content
X2Community Forums

Gravity Forms Integration Solution [SOLVED AND AVAILABLE]

Recommended Posts

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.x2crm.com/topic/3680-testing-my-api-but-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.

  • Like 6
Link to post
Share on other sites
  • 4 months later...

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.

Link to post
Share on other sites
  • 3 weeks later...

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:



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-upload.eu/bild-10cea5-1551098178.png.html




  • Like 1
Link to post
Share on other sites

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.





  • Like 1
Link to post
Share on other sites
  • 1 month later...

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):


$request = new HttpRequest();
  'assignedTo' => 'Anyone',
  'c_Assigned_Dealer' => '1',
  'Name' => '1',
  'updatedBy' => 'Anyone',
  'visibility' => '1'
  '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.
  • Like 1
Link to post
Share on other sites

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.

Link to post
Share on other sites

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. 

Link to post
Share on other sites

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.





Link to post
Share on other sites

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.x2crm.com/topic/2237-basic-test-for-web-lead-capture-missing-or-malformed-data-sent-to-server-400/)  which I adapted for it to work from any server to our server. 



//Assign values
$firstName = $name;
$lastName = "$lastname";
//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_HTTPHEADER, array("Content-Type: application/json; charset=utf-8;")); 
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?
Link to post
Share on other sites
  • 1 year later...
A big thank you, Eugene, and even a bigger sorry... my provider (Cloudways) has automatically recognized the cross-posting (X2 runs on a different server than the web server) as a security problem and prevented it by the firewall.


I have now manually added the action / IP to the whitelist.


Works again :-)

  • Like 1
Link to post
Share on other sites
  • 1 year later...
  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...