I am using code to read information from Google Sheets (results from Google Forms) with C# but now I want to update a dropdown list for a specific Google forms with C#. I have seen code where you can update a dropdown list with google app script (https://developers.google.com/apps-script/reference/forms )but I can not find code to do this within C#. It is possible within C# to update a google sheet so you should think it is possible to do the same with Google Forms. Does anyone done this?
The example i have found is very simple within app script
var existingForm = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var item = form.getitembyid(3567489);
var values = ["oranges", "Tomatoes"]
item.asListItem().setChoicesValues(values);
There is no Forms API, so you cannot do this directly with C#. Because of this, the only option, if you want to do this programmatically, is using Apps Script.
There are workarounds, though, to "wrap" the Apps Script, and call it remotely from your C# program:
Workaround #1 (Apps Script Web App):
You could publish your script as a web app and use this as a URL endpoint that you will access with your C# application. The web app would receive the HTTP requests from your application, and edit the form. For example, you could do a POST request with data about the items you want to edit, and use the corresponding event object to retrieve that information. It could be something along these lines:
function doPost(e) {
var formId = e.parameter.id; // Your form id
var itemId = e.parameter.itemId; // Your item id
var form = FormApp.openById(formId);
var item = form.getItemById(itemId);
var values = e.parameters.values; // ["oranges", "Tomatoes"]
item.asListItem().setChoicesValues(values);
}
Workaround #2 (Apps Script API):
Another way, if you want to edit your form remotely from your C# application, is to use Apps Script API to create and run the Apps Script project that contains the code for editing the form. Beware, this is not an easy way, and it would take several steps:
Get access to the Form via OAuth 2.0.
Using this library, create a project with Apps Script API, by using the method projects.create. I'd suggest you to create a project that is bound to the Form, so that you don't need to authorize the script when it's time to execute it. If you do that, you would need to specify the parentId in your request body (and in your script you could use FormApp.getActiveForm() instead, which wouldn't require authorization).
Using the scriptId retrieved from the response in previous step, call projects.updateContent, in which you would have to add the code corresponding to the files in your project.
Call scripts.run to execute your code an update your form. If you have created a standalone script in step 2, you will have to authorize your project via OAuth 2.0.
Reference:
Apps Script Web Apps
Using OAuth 2.0 to Access Google APIs
Google Apps Script API
Apps Script API Client Library for .NET
Related
I have created a web application in .Net core(v5.0) and hosted it in Azure App Service. I have created a view and that allows me to add a new URL based on that create a new subdomain in the same service and publish code in that. This concept also uses in Jira software where our <projectname>.atlassian.com
Eg:
I have added dev in a text box then-new subdomain added like. dev.<myappservicename>.azurewebsites.net
In this case, all code copy and run this code properly.
Main Domain:
Base URL(Created URL): <myappservicename>.azurewebsites.net
Custom URL(Added from View): dev.<myappservicename>.azurewebsites.net
,
admin.<myappservicename>.azurewebsites.net
Technology Specification:
.Net Core(5.0)
C#
Azure App Service
If anyone has an idea then suggest thought.
It helps me a lot.
You can use restapi or .net sdk to create subdomain.
From your description, I see that there should be no need to redeploy your webapp, so if there is a business need, it is recommended to identify it through the program, what is the input url of the browser, to process your program.
Eg:
company1.<projec_tname>.azurewebsites.net
Get HttpRequest url to handle company1's bussiness.
company2.<projec_tname>.azurewebsites.net
Get HttpRequest url to handle company2's bussiness.
I have a scenario where I would like to automate programmatically the following process:
Currently, I have to manually
Navigate to a webpage
Enter some text (an email) in a certain field on the webpage
Press the 'Search' button, which generates a new page containing a Table with the results on it.
Manually scroll through the generated results table and extract 4 pieces of information.
Is there a way for me to do this from a Desktop WPF App using C# ?
I am aware there is a WebClient type that can download a string, presumably of the content of the webpage, but I don't see how that would help me.
My knowledge of web based stuff is pretty non-existent so I am quite lost how to go about this, or even if this is possible.
I think a web driver is what you're looking for, I would suggest using Selenium, you can navigate to sites and send input or clicks to specific elements in them.
Well, I'll write the algorithm for you but you also need to some homework.
UseWebClient get the htm page with the form you want to auto fill and submit
Us regex and extract the action attribute of the form you want to auto submit. That gets you the URL you want to submit your next request to.
Since you know the fields in that form, create a class corresponding to those fields, let's call the class AutoClass
Create a new instance of your auto class and assign values you want to auto fill
Using WebClient to send your new request with the url you extracted from the form previously, attach your object which you want to send to the server either through serialization or any method.
Send the request and wait for feedback, then further action
Either use a web driver like Puppeteer (Selenium is kinda dead) or use HTTPS protocol to make web requests (if you don't get stopped by bot checks). I feel like your looking for the latter method because there is no reason to use a web driver in this case when a lighter method like HTTP requests can be used.
You can use RestSharp or the built in libraries if you want. Here is a popular thread of the ways to send requests with the libraries built in to C#.
To figure out what you need to send you should use a tool like Fiddler or Chrome Dev Tools (specifically the Network tab) to see what you need to send to acheive your goal as you would in a browser.
Hi I'm currently refreshing my knowledge in C# programming.
I wanted to translate the manual way of creating a Web App in Microsoft Azure (Classic) into the C# language.
(Manual way - New > Compute > Web App > Custom Create > ...etc.. )
Whenever I search through google about this topic all it gives me is to literally create a "WebApp" in Visual Studio. (File > New > ...etc...) However, what I am looking for is how to create an Azure Web App programatically via C# - how to interact with the Management UI of the Classic Azure Portal to create a web app.
Anyone familiar to do this? Thanks in advance for the help! :)
To create an azure website easily using C#, you can use "Windows Azure Management Libraries". This SDK is a wrapper arround "Azure Service Management" API.
Here is a introduction from Braddy Gaster an a blog post, to get credentials from an Azure Tenant an work with ASM Api.
Then you will be able to create a website with something like this :
using (var AwsManagement = new Microsoft.WindowsAzure.Management.WebSites.WebSiteManagementClient(azureCredentials))
{
WebSiteCreateParameters parameters = new WebSiteCreateParameters()
{
Name = "myAws",
// this Service Plan must be created before
ServerFarm = "myServiceplan",
};
await AwsManagement.WebSites.CreateAsync("myWebSpace", parameters, CancellationToken.None);
}
I was able to work on the available code Microsoft posted in GitHub:
https://github.com/Azure/azure-sdk-for-net
I re-coded some and just acquired the functions that I only need for my program to work. :)
You can create a web site by using a POST request that includes the name of the web site and other information in the request body. You can check the code example for ASM here.
I have been following the online tutorials provides on Azure and WP series. So far I have been able to understand flow of "TODO application" which is built.
I followed the guidelines provided and created my own WP 8.1 "User registration app". I have created the following in Azure.
Mobile Service
Database and required tables and required columns for this application
I have also written StoredProc which provides OUTPUT result upon success and failure.
When I tried to call this storedproc I was not able to access or to be more honest, I don't have any idea on how to call this or go about. I have been looking around places which were pointing to use "Mobile service API" then call the StoredProc function etc which made me more confused.
How to solve this?
What I need to achieve is, from the WP app I have written, the user key-in the required values, click on "register" button, the function should call Storedproc by passing all the values from WP app to StoredProc as parameter, upon successful execution of StoredProc, it returns a RESULT value which my application need to use and save a system generated value in WP isolated storage, so when next time application loads, it will check for this file, if available the application loads if not it will navigate the user to registration page.
I have been able to pull out sample on isolated storage and other stuff, but not able to achieve with respect to StoredProc and sending and receiving the data to and from Azure SQL Server.
Please help - Thanks in advance.
Depending on which sort of Mobile Services backend you have (Node or C#) you can invoke stored procedures using a pattern similar to the following:
function(request, response) {
var mssql = request.service.mssql;
mssql.query("EXEC <<your_sproc_name>> ?", request.query.<<your_query_prop_here>>, {
success: function(results) {
// console.log(results) <-- use for debugging
// return results (or pass to another function)
}
});
};
If this doesn't really answer the question fully it's worth looking at the Azure Mobile Services Custom APIs documentation which will cover this scenario in more detail.
I have an app which uploads an xml to the server via ajax and does some processing liking parsing,schema validation,connecting to the db based on the conn string present in the xml data.These validations,connection and data extraction is being done in the same function of the controller. I want to update my viewer the steps that has already been completed. Since I cannot return the function ,so I created a file in which the the given function will write the update and another ajax call via different function of the same controller will read the file and display it on the page.This is working fine except that if i connect to the app from two browsers the information get overlapped. What other alternative can you suggest?
Are you using dotnet 4.5? Would it be possible for you to use SignalR, at various points your controllers action to send back progress messages to the browser?
You should also consider using Async methods