Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

help wanted: post only returns "AnkiConnect v.6" #401

@TheGha

Description

@TheGha

Hi, i am trying to figure this out in C#, since that is the language i am the most used to by far. but this is the first time i am doing http, and jsons in this manner.
to dumb it down to general coding concepts:
i am posting to "http://localhost:8765"
with the string "{"action":"findNotes","version":6,"params":{"cards":"deck:current"}}"
and the response i am getting is "AnkiConnect v.6"

the relevant code lines are:

using HttpClient httpClient = new() { BaseAddress = new Uri("http://localhost:8765"), };
public class Params1
{
    public string cards { get; set; }
}

public class GetCards
{
    public string action { get; set; }
    public int version { get; set; }
    public Params1 @params { get; set; }
}

and

Params1 params1 = new Params1();
params1.cards = "deck:current";
GetCards getCards = new GetCards();
getCards.action = "findNotes";
getCards.@params = params1;
getCards.version = 6;


string json1 = JsonSerializer.Serialize(getCards);
Console.WriteLine("json sent: " + json1);

HttpResponseMessage response = await httpClient.PostAsJsonAsync(
"",
getCards);

string jsonResponse = await response.Content.ReadAsStringAsync();

Console.WriteLine("response: " +jsonResponse);

giving me this in the console:

json sent: {"action":"findNotes","version":6,"params":{"cards":"deck:current"}}
response: AnkiConnect v.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions