How do I manipulate and submit data through GET and POST?

Asked

Viewed 69 times

0

I have a web application and need to access an external url that has login and password. Later I must fill out a form, submit the data and receive the feedback in my application!

This is possible using C#(GET, POST http web requests)?

  • It depends on how you authenticate this external url, explain your scenario better, show the code how you’re doing and point out where you’re finding the error.

1 answer

2

The communication between web applications is actually through HTTP, it is possible yes you do this communication through the verbs (also known as methods) GET and POST.

In C# I use a very nice framework called Flurl, the link to access it is this. The site has extensive documentation of how to use it for various purposes.

In your case, the login and password will possibly be sent by a POST request, which can be sent by JSON.

await "http://site.com.br".PostJsonAsync(new { login = "blabla", senha = "teste" });

To recover the resource through GET is even simpler.

var response = await "http://site.com.br".GetJsonAsync();

In the above case you receive an Object dynamically, but you can set the strongly typed mapping for some specific class.

SuaClasse obj = await "http://site.com.br".GetJsonAsync<SuaClasse>();

I use a lot to consume RESTFUL Apis and in my opinion it is very practical.

I hope I’ve helped! :)

  • Oops, thanks, I’ll check the documentation!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.