I'm at a loss here guys. The documentation sucks, I feel like I'm on an island, and I'm way behind in my project. Hoping there might be someone, anyone that might have a clue as to how to create a ledger entry and relate it back to an invoice.
I'm at a loss here guys. The documentation sucks, I feel like I'm on an island, and I'm way behind in my project. Hoping there might be someone, anyone that might have a clue as to how to create a ledger entry and relate it back to an invoice.
The API documentation improved over time, but I was still on my own while attempting to complete this task. I did finally figure it out and for anyone else that needs help with this, below are the steps I took to create a Ledger Entry (and Ledger Item).
Creation of Ledger Entry:
var requestUrl = string.Format("{0}/services/data/{1}/sobjects/{2}", _url, _version, SageObjectNames.LedgerEntry); var client = new RestClient(requestUrl); var request = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json }; request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + _auth); request.AddParameter("application/json; charset=utf-8", "{ \"s2cor__Code__c\":\"" + reference + "\", \"s2cor__Date__c\": \"" + date.ToString("yyyy-MM-dd") + "\" }", ParameterType.RequestBody); var response = client.Execute(request); var jobject = JsonConvert.DeserializeObject<JObject>(response.Content); var entryId = jobject["id"].ToString();
Creating a Ledger Item for a Ledger Entry:
var requestUrl = string.Format("{0}/services/data/{1}/sobjects/{2}", _url, _version, SageObjectNames.LedgerItem); var client = new RestClient(requestUrl); var request = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json }; request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + _auth); request.AddParameter("application/json; charset=utf-8", "{ \"s2cor__Ledger_Entry__c\": \"" + ledgerEntryId + "\", \"s2cor__Ledger_Account__c\":\"" + ledgerAccountId + "\", \"s2cor__Base_Credit__c\": " + baseCredit.ToString() + ", \"s2cor__Base_Debit__c\": " + baseDebit.ToString() + ", \"s2cor__Description__c\":" + description + " }", ParameterType.RequestBody); var response = client.Execute(request); var jobject = JsonConvert.DeserializeObject<JObject>(response.Content); var itemId = jobject["id"].ToString();
Hope this helps others get started. I use RestSharp (NuGet Package) and a host of other base methods that help me build the request and retrieve the response (deserialize).