Jump to content

Stuart Eastland

  • Content Count

  • Joined

  • Last visited

  • Days Won


Stuart Eastland last won the day on February 24

Stuart Eastland had the most liked content!

Community Reputation

3 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I've just gone through the process of getting the oAuth callback to work and have posted simplistic demo code in an earlier thread: Oauth2 Authorisation and IIS - Support - Sage Developer Community You need to have logic in the callback to retrieve the code sent from sage and then request the tokens. I found this easiest to do on a development machine using localhost. If you don't use localhost you need to use https. One thing to note is the token is refreshed without using the callback url, so it may be something that you only need to do initially as long as your refres
  2. Thanks Ben, that works perfectly although it does mean a second request when creating new products/contacts. Also your pointers to the "key concepts" in your help pages should reduce the number of further questions from me 😁 My project to allow our in-house system to push products, contacts and sales invoices directly into Sage went live this week following our migration from sage50 and should result in significant time (and error) savings. However, the json in your previous answer makes me question the best way for me to deal with paginated queries. I understand the principle
  3. I am able to push sales invoices into Sage using the API, however some of these need to be PROFORMA. When creating a new invoice online I can set the dropdown to DRAFT or PROFORMA but I cannot see any such option in the API.
  4. Here is my commented pseudo-code for the callback.Please feel free to peer-review and make suggestions for improvement. public partial class SageCallback : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.Params["code"] == null) { Response.Redirect("Default.aspx?Message=Missing [code] parameter in sage callback request."); } RestClient client = new RestClient("https://oauth.accounting.sage.com/token"); RestRequest request = new
  5. Here is my commented pseudo-code for getting the token. I'll post the code for the callback separately. Please feel free to peer-review and make suggestions for improvement. private static string GetOAuthToken() { User currentUser = new <persisted user data >; // if the token has not expired, use it if (currentUser.SageAccessTokenExpiry != DateTime.MinValue && currentUser.SageAccessTokenExpiry > DateTime.UtcNow) { return currentUser.SageAccessToken; }
  6. Hi Ben, I wonder if you can help me again? Your suggestion to use the links/href in the contact json resolved my requirements for contacts, however the products uses the same dual unique key scenario where the API requires the 32 character key and the pages require a numeric id which I cannot find anywhere in the json returned or a product. This does not have a links section. So, how do I find this numeric id for a product so I can construct a link from our internal website?
  7. In answer to my own question, I clearly need to use an SSL secured url that can be resolved externally so I need to get an SSL certificate installed on the server as my next step.
  8. I have been working on using the API running on a development machine with our website and oAuth callback on localhost. Just installed on our server which is running inside a fire wall and now get www.sageone.com refused to connect when trying to fetch the oauth token. I am using an internal ip address. Is this going to be possible? I figured that localhost was also local so a local ip address should work too.
  9. I started trying to do this in December. There is no API for sage50. We just migrated to Sage Online, far superior and excellent API. Task completed in a couple of days including full integration or products, customers and suppliers.
  10. Thanks. That is perfect. I thought that I had looked through the returned json but maybe missed this. I think the issue with the reference number is that the migration populated the reference number with the original invoice number and the invoice number with a transaction number that previously had not been visible to end users. This means that all our sales invoices now have different numbers to those sent to our customers. I anticipate some frustration when we start getting queries on these! I have not been very impressed by the migration. I don't see why the data abov
  11. We push sales invoices from our in-house system into sage using the API, a process that also creates customers and suppliers in Sage if required. When I create a Contact (customer or vendor) using the API I get a 32 character "id" and the $path shows as /contacts/abcde where abcde is the 32 character id. When I use Sage online and search for a contact the resulting url looks like /contacts/customers/12345678 where 12345678 is an 8 digit numeric id which I cannot find in the data returned from Sage when I do a Contact GET. I note that the API uses the 32 character id when creating sales
  12. I am using POST to create a new sales order but I get an error saying that "contact cannot be found". I am using a unique reference for all my contacts which matches the database id from our in-house database as a lookup on contacts (customer/supplier), however I am supplying the numeric "id" for a customer which I get from the customer details page url when using the api.
  13. I was not building my request correctly and I can now get the token back using my c# code. I found the sample code rather difficult to follow as I am an old school ASP Forms developer (no MVC or SPA) so I stripped it right down the the basic Request/Response mechanism and cut it down significantly.
  14. I have noticed that the code that is returned (and the one in the sample code from Authentication | Sage Developer | Accounting) starts with "GB/" which looks like to country code. The sample request for a token has stripped this off. Is this correct? Response: GET https://myapp.com/auth/callback?code=GB%2F12abcxxxxxxxxxxxxf7d&country=GB&state=random_string Request: POST https://oauth.accounting.sage.com/token Content-Type: application/x-www-form-urlencoded client_id=4b6xxxxxxx710 &client_secret=iNuxxxxxxxxxxtm9 &code=12axxxxxxxxxxxxf7d &grant_type=authoriz
  15. I found that my initial problem was the value I was supplying for scope was incorrect. I am now able to make the initial request and get a code returned, however when I send this back for a token I am getting a http 400 error. I'll compare my request string with the postman values...
  • Create New...