Sage / sageone_api_php_sample

Sage One API PHP Sample
MIT License
43 stars 32 forks source link

Ledger account ID #66

Closed anchordigi closed 3 years ago

anchordigi commented 3 years ago

Hi,

I'm trying to create an invoice using the API and this sample as a basis. I've got everything working except that I can't work out how to find the right ledger ID.

Is there anywhere within Sage I can find this? Or else do I need to use the API to access it? I've used the ledger_accounts endpoint and a GET request, and that retrieves them, but I can't figure out how to use the pagination to find the ledger account I need.

So i'm either looking for where I can find the ID within Sage itself, or how to use pagination parameters with the API.

Thanks for any help!

cpetschnig commented 3 years ago

Hi,

you probably want to use the visible_is filter for ledger accounts as described here in the API reference. This should even be possible without pagination, especially if you set items_per_page to 200.

Does this help? Cheers!

anchordigi commented 3 years ago

Thanks for the quick response. My issue is not knowing how to set 'items_per_page'.

Here is my request: $response = $apiClient->execApiRequest('ledger_accounts', 'get');

I'm not sure how to set 'items_per_page'?

cpetschnig commented 3 years ago

Did you try

$response = $apiClient->execApiRequest('ledger_accounts?items_per_page=200', 'get');

Maybe

$response = $apiClient->execApiRequest('ledger_accounts?items_per_page=200&visible_in=sales', 'get');

is even more helpful. Does this take you forward?

anchordigi commented 3 years ago

I definitely thought I had tried that, but I gave it another go and it worked! I was doing it late last night so probably made a typo or something.

Thanks so much for your help, it's really appreciated. Hope you have a great rest of your day.

cpetschnig commented 3 years ago

Solved