Skip to content

Instantly share code, notes, and snippets.

@wtneal
Last active July 31, 2019 20:37
Show Gist options
  • Save wtneal/501deb4287ff958bb019af7fda16a334 to your computer and use it in GitHub Desktop.
Save wtneal/501deb4287ff958bb019af7fda16a334 to your computer and use it in GitHub Desktop.
DataDivers Integration HTTP Post

Option 1: HTTP Request

This might work using the built in HTTP Request functionality. The main concern is that the body XML string needs to be url encoded for this to work properly. Does this happen automatically or does this need to be done with another call or manually?

I don't know if this functionality is available to all versions or what version you may be running.

C_TEXT($response)
// build the form inside the body, e.g. `field1=value1&field2=value2`
$body_t:="query=<?xml version=\"1.0\" encoding=\"UTF-8\"?>...rest of xml goes here"
HTTP Request(HTTP POST method;"https://www.edatadivers.com/webservices/default.cfm";$body_t;$response)

Sources

Option 2: cURL

cURL seems to be an option, but seems to be a plugin for the software. Making a POST with cURL is probably similar to how it is done in PHP, where you set cURL options and make then execute the request. I don't know which plugin or version you are using, but since it is probably a simple wrapper around cURL this should work just fine (I can't know without testing).

Looking at the cURL plugin documentation it seems provides a utility to escape/url encode strings. escaped:=cURL Escape url (url). This could be used on any string not just a url so this could be used to get the form data how it needs to be.

C_BLOB($in;$out)
C_LONGINT($err)

$xmlRequest:="<?xml version=\"1.0\" encoding=\"UTF-8\"?>...rest of xml goes here"
$xmlRequestEncoded:=cURL Escape url ($xmlRequest)

$formData:="query="+$xmlRequestEncoded

ARRAY LONGINT($optionNames;0)
ARRAY TEXT($optionValues;0)

// any other cURL options

// Add the POST Fields String
APPEND TO ARRAY($optionNames;CURLOPT_POSTFIELDS)
APPEND TO ARRAY($optionValues;$formData)

// any other cURL options

$err:=cURL ("https://www.edatadivers.com/webservices/default.cfm";$optionNames;$optionValues;$in;$out)

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment