0

Python code that works completely:

import requests

base_adress = 'https://api.curseforge.com'

headers = {
  'Accept': 'application/json',
  'x-api-key': ''
}

r = requests.get(base_adress + '/v1/mods/search', params={
  'gameId': '432',
  'searchFilter': 'Applied Energistics 2'
}, headers = headers)

print(r.json())

my implementation of py code in C#, which doesn't work:

var baseUrl = new Uri("https://api.curseforge.com");

using var client = new HttpClient();
client.BaseAddress = baseUrl;
using var request = new HttpRequestMessage(HttpMethod.Get, "/v1/mods/search");

request.Headers.Add("Accept", "application/json");
request.Headers.Add("x-api-key", "");
request.Options.Set(new HttpRequestOptionsKey<Int32>("gameId"), 432);
request.Options.Set(new HttpRequestOptionsKey<string>("searchFilter"), "Applied Energistics 2");

var response = await client.SendAsync(request);
var text = await response.Content.ReadAsStringAsync();
Console.WriteLine(text);

I want to send GET request (https://docs.curseforge.com/?python#search-mods) with two PATH and two QUERY parameters. it works very well, as long as i dont need to use a GET request with some "query" parameters. As i understand it: PATH - request.Headers (i've already checked it, so it really is), and Query - is request.Options, but i can't make sure of this, because when i want to use a method where Query parameters are required, then everything stops working. Please help me :( I want to get an response in C#, the same as in Python:(

C# Output

{"data":[],"pagination":{"index":0,"pageSize":50,"resultCount":0,"totalCount":0}}

Python Output contains 50k+ lines with mods ids and much more

NMNKFF
  • 13
  • 3

0 Answers0