Jump to content

Recommended Posts

Posted

I can connect and get data from https://api.accounting.sage.com/v3.1/  using Postman OK.  In Postman I can set the call back URL to the same as my App at developerselfservice.sageone.com .

However, I need to create a program in Visual Studio to read data from WooCommerce orders and add them as Invoices to Sage.

I've looked at the C# sample app on github and cannot get this to work as it is.   I'm using VS 2022 and targeting Net6.0, and the app builds OK.

I keep hitting the https://central.uk.sageone.com/errors/oauth-failed page and the problem seems to be that it's not getting a valid (same as my app) callback url.

In the github sample app code the callback url is read from the json file to a string named 'config_calback_url' which is then never used in the code  - so is pointless.  Instructions say to make sure the 'client_application.json' has the correct callback url saved - but this is never used in the code.

1981665415_Screenshot2022-07-08132946.thumb.png.70e02741477b9786c40ee1084368e185.png

I've tried changing the 'CallbackPath' to be the correct callback url, but cannot as the Path can only begin with a / so a full url cannot be used.  I've tried all combinations of localhost and also tried setting the application.json iissettings to be my registered app callback (the one that works in Postman),  but nothing works.

2084957440_Screenshot2022-07-08132728.png.34475c97c6227356e56be0e7fefe508c.png

I've even tried to add extra callback urls to the app settings on developerselfservice.sageone.com , but I cannot enter anymore Callback URLs as shown above.  When I do and then click 'Save', nothing is saved!!

As can be seen below, I can connect OK with Postman, but your recommended sample app won't work.  Is there something I'm missing??

286400085_Screenshot2022-07-08140355.thumb.png.2f1167d9d8f0519f34ec0ebc807b886a.png

Do you have an updated example of connecting to the API with C#? 

Thanks

 

Posted

I've figured it out now after ignoring the instructions given.  The clue is in the Guide.cshtml page, but the catch22 is that this is not displayed until you've figured the issue. Great sample from 2020.

Posted

Hi Gavin, I'm pleased you've been able to resolve your issue.

As you found, the example code available is a little dated. We're about to commence on improving the example code available to our community and hope to be able to share this content in the coming weeks and months.

Thanks

Mark

  • 8 months later...
Posted

Hi,

 

I'm facing exactly the same issue and given I'm trying to interface a winforms app I could really do with the example working to help with my understanding/refactoring/reachitecting... (i can talk to QB and Xero in this fashion)

 

Any upated examples or more detail as to the fix? Any help appreciated, thanks!

Dean

Posted
On 3/15/2023 at 10:33 AM, Dean Walker said:

Hi,

 

I'm facing exactly the same issue and given I'm trying to interface a winforms app I could really do with the example working to help with my understanding/refactoring/reachitecting... (i can talk to QB and Xero in this fashion)

 

Any upated examples or more detail as to the fix? Any help appreciated, thanks!

Dean

Hi,

I am having the same problem. Whatever callback URL I am using I get the the message that the backend service is temporarily not available and I shall try later.

 

cache-control: no-cache, no-store
cf-cache-status: DYNAMIC
cf-ray: 7aacad022d601621-DUS
content-type: text/html; charset=utf-8
date: Mon, 20 Mar 2023 08:44:53 GMT
server: cloudflare
set-cookie: _session_id=1e1ebb88a48077542888554260d325ba; path=/; expires=Mon, 20 Mar 2023 10:14:53 -0000; HttpOnly
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
x-correlation-context: {}
x-frame-options: SAMEORIGIN
x-request-id: 482dc3c1-aa9c-4439-a19c-db1bfef6f1f5
x-runtime: 0.262194
x-xss-protection: 1; mode=block
 

Please advice.

Stefan

Posted

HI Stefan,

 
Your problem maybe to do with an ongoing issue with our auth Server.  The issue looks to be related to the authenticating of businesses recently provisioned and does not appear to affect applications which are currently maintaining an access_token.

If you can provide the below information relating to your business that would be helpful:
 
Business info Required
 
  • Business Name
  • Email Address used to access the Sage Business Cloud Accounting Business
  • The Date the business was created
  • The region(CA, ES, FR, IRE, UK, US) the business was created for
Thanks
 
Mark
Posted

I "fixed" my issue by not using the Sage examples and just refactoring some choice bits of the Xero.Net.Standard OAUTH2 wrapper library...

I've yet to try and pull/push data (other than using postman) but i guess i'll be classing up some models for your data, I already have a bunch of SDO code I've been using for desktop that i knocked up about 20 years ago, are any of those fields/structures applicable to the cloud system? i.e. Account and Service Invoice?

Thanks!

Posted

Hi Dean,

Sage Data Objects is applicable only to the UK version of Sage 50 Cloud Accounts. SDO is a very low level access component that represent the flat files db structure of Sage 50. There will be very little or none of that code that can be reused with SBCA.

Thanks

Mark

  • 9 months later...
Posted
On 7/8/2022 at 4:54 PM, Gavin Edge said:

I've figured it out now after ignoring the instructions given.  The clue is in the Guide.cshtml page, but the catch22 is that this is not displayed until you've figured the issue. Great sample from 2020.

Hello Gavin,

Sorry for being dense, I'm in the same situation you were a couple of years ago but I can't understand how did you fix it, can you help me out?

Thanks

Posted
3 hours ago, Claudio Borghi said:

Hello Gavin,

Sorry for being dense, I'm in the same situation you were a couple of years ago but I can't understand how did you fix it, can you help me out?

Thanks

found the fix

on the app you'll need to register the callback URL

"http://localhost:<port>/auth/callback",

while in the clien_application.json you'll need to set the value

"callback_url": "https://localhost:<port>/"

That wasn't at all an unnecessary waste of time 🙂

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...