misc_bb 7 Posted March 10, 2021 (edited) Anyone integrating an API with Delphi (currently using Delphi Sydney 10.4) with accounting software like Quickbooks? I wonder if anyone encountered an issue with REST components integration with Quickbooks. Currently, we already have an implementation with Xero and MYOB using the same structure which is working really well. However, when I implemented the same with Quickbooks I got a empty JSON string with no errors at all or whatsoever. Quickbooks API did return me an authentication code but exchanging this code for the access token leaves me nothing. It just return an empty JSON string with no errors or exception. Any idea where I can further check on this within the Delphi environment? I'm also requesting a trace for my API integration with Quickbooks support to see if the request really push thru. Any input would be appreciated. Many thanks! Edited March 10, 2021 by misc_bb Share this post Link to post
misc_bb 7 Posted March 12, 2021 (edited) I guess not all APIs are created equal. I was able to figure out my problem by changing the body parameters to: TRESTRequestParameterKind.pkREQUESTBODY to TRESTRequestParameterKind.pkGETorPOST This is one of the function (Exchanging the code for tokens) we have for Quickbooks API integration. I have Xero and MYOB almost exactly the same code but this one wants to be different. Different APIs have different way of interacting with the Delphi REST component. It's probably the API design. In their API documentation they indicated that this is part of the "Body", so we also indicate that its part of the request body in our code but then it has a different result. So just in case you encounter these issues, sometimes it's trial and error. RESTRequest := TRESTRequest.create(nil); RESTRequest.Client := TRESTClient.create(RESTRequest); RESTRequest.SynchronizedEvents := False; RESTRequest.Client.UserAgent := qb_UserAGent; RESTRequest.Client.BaseURL := 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'; RESTRequest.Client.Accept := 'application/json'; RESTRequest.Client.ContentType := 'application/x-www-form-urlencoded'; RESTRequest.Client.Params.AddItem('Authorization', QuickbooksGetAuthorization, TRESTRequestParameterkind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]); //QuickbooksGetAuthorization - calls for the Base64 encoded authorization RESTRequest.Client.Params.AddItem('Host', 'oauth.platform.intuit.com', TRESTRequestParameterkind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]); //not sure if this was really required RESTRequest.Params.AddItem('grant_type', 'authorization_code', TRESTRequestParameterKind.pkGETorPOST); RESTRequest.Params.AddItem('code', authCode, TRESTRequestParameterKind.pkGETorPOST); //authCode - variable that stores the authentication code RESTRequest.Params.AddItem('redirect_uri', qb_RedirectURI, TRESTRequestParameterKind.pkGETorPOST); //qb_RedirectURI - variables that stores the redirectURI RESTRequest.Method := rmPOST; RESTRequest.Response := TRESTResponse.Create(RESTRequest); RESTRequest.Execute; Result := RESTRequest.Response.Content; Just sharing maybe some of you wants to implement the same 🙂 Edited March 12, 2021 by misc_bb 1 Share this post Link to post
TimWinstanley 0 Posted March 15, 2021 Thanks - could be useful. Were you tempted to use the "free" CDATA connectors ? I've tried and they seem to work - if a little (lot!) slow.... Share this post Link to post
misc_bb 7 Posted March 15, 2021 We were actually using Indy with Xero OAuth 1.0 but we just want to take advantage of the new features that the new Delphi versions is offering. So far all good with some few hiccups along the way but was able to get around with it. Share this post Link to post
Zath 0 Posted June 29, 2021 On 3/15/2021 at 5:50 PM, TimWinstanley said: Thanks - could be useful. Were you tempted to use the "free" CDATA connectors ? I've tried and they seem to work - if a little (lot!) slow.... Free only for the first year it seems. I was watching a recent Embarcadero webinar TandCoffee or somesuch and they weren't sure if that was the case either. I use Quickbooks Desktop Accountant at work. Share this post Link to post
Lars Fosdal 1792 Posted June 30, 2021 The CData connectors are generic crap, and their license fees are exorbitant. Share this post Link to post
Geoffrey Smith 45 Posted July 31, 2021 I have created a demo project that you could look at here https://github.com/geoffsmith82/DelphiIntuitAccess 2 Share this post Link to post