Wie sende ich eine Microsoft Forms -Antwort mithilfe von HTTP Web Client Post Async?C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Wie sende ich eine Microsoft Forms -Antwort mithilfe von HTTP Web Client Post Async?

Post by Anonymous »

Ich habe ein öffentliches Microsoft -Formular.

Code: Select all

   private async void TryMicrosoftFormsURLDataSend() {
Dictionary postData = new Dictionary() {
{ "answers", "[{\"questionId\":\"rcd067ebc52564793af6b62108cc4e4a3\",\"answer1\":\"John\"}]" },  // Replace with the field IDs and the answers
{ "startDate", "2025-04-07T19:13:21.728Z" },
{ "submitDate", "2025-04-07T19:13:42.169Z" }
// Add more fields as necessary
};
using (HttpClient client = new HttpClient())
{
var content = new FormUrlEncodedContent(postData);
var response = await client.PostAsync("https://forms.office.com/formapi/api/9188040d-6c67-4c5b-b112-36a304b66dad/users/00000000-0000-0000-0006-bffdc09daf51/forms('DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAa__cCdr1FUOVlIWVRRUzNYWFlVNzQ4UzdNRjVHM0VTTy4u')/responses", content);

if (response.IsSuccessStatusCode)
{
Debug.Log("Response successfully submitted!");
}
else
{
Debug.Log("Failed to submit response:" + "\n" + response.Content + "\n" + response.ReasonPhrase);
}
}
}
This is printed to console:
Failed to submit response:
System.Net.Http.StreamContent
Bad Request
Tried the same removing the "users/00000000-0000-0000-0006-bffdc09daf51/" bit (That's how it works in Google Formulare), aber nicht funktioniert und dies wird stattdessen gedruckt: < /p>
Die Antwort nicht einreicht:
system.net.http.streamContent
Methode ist nicht zugelassen < /p>
Ich habe nicht viel Erfahrung mit HTTPCLIENTS, da ich ein Spielprogrammierer bin. Danke.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post