Creating objects using the API

Hi all,

First off, let me quickly mention how impressed I am with Manager.

Seriously good software.

I am about to launch a number of on-line retail stores and wish to integrate my e-commerce stores with Manager. I have searched the forum but cannot find an example of posting to the API. I have tried posting what I assumed was meant on the journal entry API page however my code is not working.

I was wondering if someone would help point me the right direction?

Here is the basic code I have that does not work.

Thanks and best wishes
James

<?PHP
$data_string = '{"Date": "2016-11-29",
  "Narration": "Test entry",
  "Lines": [
    {
      "Account": "f0dd2220-ef8d-43d0-b2de-d3a2010c0baa",
      "TaxCode": "8cf9d117-3142-4d9c-82ee-b57a0eb2c4809",
      "Credit": 1000.0
    },
    {
      "Account": "68934d51-7382-4f90-a96d-64aa9d2ab543",
      "Debit": 1000.0
    }
  ]
}
';

$ch = curl_init('http://accounts:8080/api/7ca1fcc2-619f-4415-8165-383e7f9e84bc/5ea52bc4-90ae-4e4a-aec4-ef1224b279ad');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);

$result = curl_exec($ch);
echo $result;

Hi again,
Please disregard my previous post. It was late and I have since figured out where I was going wrong.

I had not added the authentication information into cURL opts:

curl_setopt($ch, CURLOPT_USERPWD, $username . “:” . $password);

I then created a new user within Manager and passed the details to the above line.

@lubos, you really need to put a ‘Donate’ button up somewhere. Once I’ve finished testing the server version, I will buy a copy but would like the ability to donate funds to you to further your efforts, too.

Kind regards,
James

1 Like

If anyone else is trying to get the API working with PHP, feel free to message me and I’ll happily explain.

How to get all the variables which is used in manager ?

@ShubSingh39, see this guide:

Your post was edited to remove personal information. Your question has been answered several times on the forum. Searching on “variables” will turn up previous responses. Basically, all variables are used on built-in themes.

Hey @James1
I need some help regarding API with PHP. How can i contact you?

Send a private message. Click on your avatar in the upper right corner. From there, things are fairly obvious.

Thanks @tut but it doesn’t show any option to send a message, i can only see my Inbox. Perhaps the Trust Level?

Ah, yes. Because you only joined 39 minutes ago…an anti-spamming protection. If @James1 is reading the forum or has notifications set accordingly, though, s/he will see your message and may contact you.