CompaniesHouse.NET icon indicating copy to clipboard operation
CompaniesHouse.NET copied to clipboard

Companies house sandbox test api

Open robertmaxted opened this issue 2 years ago • 3 comments

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

robertmaxted avatar Jul 04 '22 14:07 robertmaxted

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

kevbite avatar Jul 07 '22 08:07 kevbite

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!

robertmaxted avatar Jul 08 '22 11:07 robertmaxted

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 );
}

kevbite avatar Jul 16 '22 18:07 kevbite