Created
December 17, 2019 20:26
-
-
Save UdaraAlwis/8d547f68ae3f629d40b2184f51acd43e to your computer and use it in GitHub Desktop.
Submit form data to your Google Form from dotnet C# with ease! ;) #GoogleFormsToolkitLibrary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Submit Form data to your Google Form | |
/// </summary> | |
/// <param name="yourGoogleFormsUrl"> | |
/// Link to your Google Form page | |
/// </param> | |
/// <param name="formData"> | |
/// Form data dictionary to submit | |
/// TKey: FieldSubmissionId - TValue: Value | |
/// </param> | |
/// <returns></returns> | |
public async Task<bool> SubmitToGoogleFormAsync(string yourGoogleFormsUrl, Dictionary<string, string> formData) | |
{ | |
// Init HttpClient to send the request | |
HttpClient client = new HttpClient(); | |
// Encode object to application/x-www-form-urlencoded MIME type | |
var content = new FormUrlEncodedContent(formData); | |
// Post the request (replace with your Google Form link) | |
var response = await client.PostAsync( | |
yourGoogleFormsUrl, | |
content); | |
if (response.StatusCode == System.Net.HttpStatusCode.OK) | |
return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment