CloudKit Web Services with ASP.NET Core server to server key auth

Hello, I have an iOS app that is still in development, and I am also making a website for it with asp.net core. I am trying to use a server to server key, but it isn't working. The response is:

{
  "uuid" : "some_uuid",
  "serverErrorCode" : "AUTHENTICATION_FAILED",
  "reason" : "Authentication failed"
}

I am using a library called EllipticCurve. You can find it here. My code is:

var requestData = new {
            zoneID = new {},
            query = new {
                recordType = "CD_Person",
                filterBy = new [] {
                    new {
                        comparator = "EQUALS",
                        fieldName = "CD_email",
                        fieldValue = new {
                            value = email,
                            type = "String"
                        }
                    }
                },
                sortBy = new [] {
                    new {
                        fieldName = "CD_email"
                    }
                }
            },
            zoneWide = "true",
            numbersAsStrings = "true"
        };
        string request = JsonSerializer.Serialize(requestData);
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-KeyID", "my_key_id");
        DateTime date = DateTime.Now;
        string iso8601Date = date.ToUniversalTime().ToString("u").Replace(" ", "T");
        client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-ISO8601Date", iso8601Date);
        byte[] bytes = Encoding.UTF8.GetBytes(request);
        SHA256 hashstring = SHA256.Create();
        byte[] hash = hashstring.ComputeHash(bytes);
        string base64Request = Convert.ToBase64String(hash);
        string paramsToSign = $"{iso8601Date}:{base64Request}:my url";
        PrivateKey privateKey = PrivateKey.fromPem("-----BEGIN EC PRIVATE KEY-----\nprivate_key\n-----END EC PRIVATE KEY-----");
        Signature signature = Ecdsa.sign(paramsToSign, privateKey);
        client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-SignatureV1", signature.toBase64());
        var content = new StringContent(request, Encoding.UTF8, "application/json");
        var response = client.PostAsync("https://api.apple-cloudkit.com/database/1/my_container/development/public/records/query", content);
        string responseString = response.Result.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseString);
        return View();

Any help would be appreciated.

CloudKit Web Services with ASP.NET Core server to server key auth
 
 
Q