kevbite/CompaniesHouse.NET

Companies house sandbox test api

robertmaxted opened this issue · 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

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

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!

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