Skip to content

Instantly share code, notes, and snippets.

@cherrykoda
Created March 22, 2021 01:13
Show Gist options
  • Save cherrykoda/14adfecc9554fa1764afae1d7e3c8db2 to your computer and use it in GitHub Desktop.
Save cherrykoda/14adfecc9554fa1764afae1d7e3c8db2 to your computer and use it in GitHub Desktop.
Curl Call for AX
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://domain.com:8201/XXXXX/SERVICENAME/xppservice.svc");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "DOMAIN\username" . ":" . "password");
$headers = array();
$headers[] = "Content-Type: text/xml; charset=\"utf-8\"";
$headers[] = "Soapaction:http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
return $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment