Salve,
potreste darmi una mano a convertire il codice JavaScript della chiamata POST che si trova nella funzione:

[COLOR=var(--color-prettylights-syntax-keyword)]async[/COLOR][COLOR=var(--color-prettylights-syntax-keyword)]function[/COLOR][COLOR=var(--color-prettylights-syntax-entity)]ryte[/COLOR]({ useCaseId, inputContexts })

https://github.com/rytr-me/documenta.../node/index.js

In un codice C#, non riesco a trovare il modo giusto, non conosco molto JavaScript, io ho provato così:

codice:

codice:
private void GetRytrContent(string _langID, string _toneID, string _usecaseID)
        {
            string api_key = "<MY-API-KEY>";


            WebRequest wr = WebRequest.Create("https://api.rytr.me/v1/ryte");
            wr.ContentType = "application/json";
            wr.Method = "POST";
            wr.Headers.Add("Authentication", "Bearer " + api_key);


            using (StreamWriter sw = new StreamWriter(wr.GetRequestStream()))
            {
                string data = "{" +


                                "\"languageId\":\"" + _langID + "\"," +
                                "\"toneId\":\"" + _toneID + "\"," +
                                "\"useCaseId\":\"" + _usecaseID + "\"," +


                                "\"inputContexts\":\"{\"<USE-CASE CONTEXT-INPUT KEY-LABEL>\":\"<VALUE>\"}," +


                                "\"variations\":\"1\"," +


                                "\"userId\":\"<UNIQUE USER ID>\"," +


                                "\"format\":\"html\"," +
                                "\"creativityLevel\":\"default\"," +


                                "}";


                sw.Write(data);
            }


            WebResponse httpResponse = (WebResponse)wr.GetResponse(); //System.Net.WebException: 'Errore del server remoto: (400) Richiesta non valida.'


            using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();


                TxtDisplay.Text = result.ToString();
            }
        }


ma mi da questo errore su
WebResponse :

//System.Net.WebException: 'Errore del server remoto: (400) Richiesta non valida.'

Questa è la curl della richiesta:

codice:
curl \
  -H "Authentication: Bearer <API KEY>" \
  -H "Content-Type: application/json" \
  -d '{"languageId": "<LANUGAGE ID>", "toneId": "<TONE ID>", "useCaseId": "<USE-CASE ID>", "inputContexts": {"<USE-CASE CONTEXT-INPUT KEY-LABEL>": "<VALUE>"}, "variations": 1, "userId": "<UNIQUE USER ID>", "format": "html", "creativityLevel": "default"}' \
  -X POST https://api.rytr.me/v1/ryte