Adding Indexer thru API

Hi,
I’m trying to make a small script to add and update sonarr indexers thru API.
I didn’t see any documentation on this topic in Github Wiki.

I have tried to look at the POST request at indexer menu when pressing save button and copied the Json as template. Unfortunately I get an ERROR 500 when trying to send this json to :
https://localhost/sonarr/api/v3/indexer?apikey=XXX

Does any one experienced this before ?

here is the debug log i get for this request:


20-4-23 17:51:39.6|Fatal|SonarrErrorPipeline|Request Failed. POST /api/indexer

[v3.0.3.750] System.NullReferenceException: Object reference not set to an instance of an object
  at Sonarr.Http.ClientSchema.SchemaBuilder.ReadFromSchema (System.Collections.Generic.List`1[T] fields, System.Type targetType) [0x0009b] in M:\BuildAgent\work\63739567f01dbcc2\src\Sonarr.Http\ClientSchema\SchemaBuilder.cs:49 
  at NzbDrone.Api.ProviderModuleBase`3[TProviderResource,TProvider,TProviderDefinition].MapToModel (TProviderDefinition definition, TProviderResource resource) [0x0009a] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Api\ProviderModuleBase.cs:138 
  at NzbDrone.Api.Indexers.IndexerModule.MapToModel (NzbDrone.Core.Indexers.IndexerDefinition definition, NzbDrone.Api.Indexers.IndexerResource resource) [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Api\Indexers\IndexerModule.cs:25 
  at NzbDrone.Api.ProviderModuleBase`3[TProviderResource,TProvider,TProviderDefinition].GetDefinition (TProviderResource providerResource, System.Boolean includeWarnings, System.Boolean validate) [0x00006] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Api\ProviderModuleBase.cs:100 
  at NzbDrone.Api.ProviderModuleBase`3[TProviderResource,TProvider,TProviderDefinition].CreateProvider (TProviderResource providerResource) [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Api\ProviderModuleBase.cs:77 
  at Sonarr.Http.REST.RestModule`1[TResource].<set_CreateResource>b__42_0 (System.Object options) [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\Sonarr.Http\REST\RestModule.cs:167 
  at Nancy.NancyModule+<>c__DisplayClass38_0`1[T].<Post>b__0 (System.Object args) [0x00047] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.NancyModule+<>c__DisplayClass40_0`1[T].<Post>b__0 (System.Object args, System.Threading.CancellationToken ct) [0x00047] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.Route`1[T].Invoke (Nancy.DynamicDictionary parameters, System.Threading.CancellationToken cancellationToken) [0x00017] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.DefaultRouteInvoker.Invoke (Nancy.Routing.Route route, System.Threading.CancellationToken cancellationToken, Nancy.DynamicDictionary parameters, Nancy.NancyContext context) [0x00086] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.DefaultRequestDispatcher.Dispatch (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken) [0x002b7] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.NancyEngine.InvokeRequestLifeCycle (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken, Nancy.Bootstrapper.IPipelines pipelines) [0x0011d] in <e31b230dbd29407fadcc55713e0bbd0f>:0

It looks like the body wasn’t properly posted possibly since it’s blowing up trying to deserialize it. Copying what the UI is doing is the closest to documentation for it at this point.

Thanks Markus for the hint,I will try to look at my query. It was late yesterday I think my eyes were not enough open :stuck_out_tongue:

Found my issue :slight_smile:
True != true

1 Like

Markus101, I’m sharing here my small script.It can help some people in updating indexers automatically.

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.