Jump to content

Setting Callback URL in API Sample C# App?


 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...