kevbite / CompaniesHouse.NET

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

Companies house sandbox test api #180

Open robertmaxted opened 2 years ago

robertmaxted commented 2 years ago

Is there a chance that you could allow the use of the companies house sandboxing api? https://developer.company-information.service.gov.uk/api-testing

kevbite commented 2 years ago

Hello @robertmaxted, you should be able to pass in a different Base URI within the settings when creating the CompaniesHouseClient https://github.com/kevbite/CompaniesHouse.NET/blob/master/src/CompaniesHouse/CompaniesHouseSettings.cs

robertmaxted commented 2 years ago

Hi Kev,

I tried that using the following uri - https://api-sandbox.company-information.service.gov.uk/

It unfortunately does not work. I tested a get using postman and it worked. But doesn't work in code. If you could try to replicate that would be great, if not then no worries. This NuGet is brilliant and I am grateful for the work you have put into it!

kevbite commented 2 years ago

Hello @robertmaxted I've just tried the sandbox uri within the settings and it works fine, doesn't return any results as I've not setup any data but returns an empty list.

string nameToSearchFor = "google";
var settings = new CompaniesHouseSettings(new Uri("https://api-sandbox.company-information.service.gov.uk"), api_key);
using (var client = new CompaniesHouseClient( settings ))
{
    var request = new SearchRequest()
    {
        Query = nameToSearchFor,
        StartIndex = 0,
        ItemsPerPage = 10
    };

    result = await client.SearchAllAsync( request );
}