kevbite / CompaniesHouse.NET

A simple .NET client wrapper for CompaniesHouse API
MIT License
37 stars 44 forks source link

Getting started with this library #68

Closed AlwaysVbNet closed 6 years ago

AlwaysVbNet commented 6 years ago

Hello, I am trying to use your library like below, but the object returned does not have any valid information. Any ideas what I'm doing wrong? Is the code updated to the latest API?

  Dim settings As New CompaniesHouseSettings("xxxxxxxxxxxxxxxxxxxxxxxxxx")
            Dim xx
            Using client As New CompaniesHouseClient(settings)
                xx = client.GetCompanyProfileAsync("12345678")
            End Using

then the "xx" object equals to:

AsyncState: nothing
CancellationPending: false
CreationOptions: none
Exception: nothing
Id = 107,
Status = WaitingForActivation {1}, 
Method = "{null}", 
Result = "{Not yet computed}
kevbite commented 6 years ago

Hello, The GetCompanyProfileAsync returns a Task<T> so you'll need to Await on the task that is returned to get the response from the call.

You should be able to change your statement of:

xx = client.GetCompanyProfileAsync("12345678")

to

xx = Await client.GetCompanyProfileAsync("12345678")

However rthis has to run within an Async method. More details about how to do asynchronous programming in VB can be found here - https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/async/

Hope this is useful, however if you have any other questions feel free to ask.

Cheers,

Kev

AlwaysVbNet commented 6 years ago

Nice library. Good work