Asked by:
Where can I go to ask questions about System.Net.HTTP?

Question
-
User-1849651236 posted
Hello,
Can anyone tell me where I can go to ask questions about using System.Net.HTTP in a C# client program?
Thanks,
TonyFriday, May 4, 2018 8:22 PM
All replies
-
User475983607 posted
Hello,
Can anyone tell me where I can go to ask questions about using System.Net.HTTP in a C# client program?
Thanks,
TonyYou can ask the question here. Keep in mind. if you are consuming a 3rd party REST service there is a limited amount of support we can provide.
Friday, May 4, 2018 8:28 PM -
User-1849651236 posted
M,
My questions concern using the Call a Web API from a .NET Client in this tutorial.
What is a 3rd party REST service? Can you give me an example?
Thanks,
TonyFriday, May 4, 2018 8:36 PM -
User475983607 posted
My questions concern using the Call a Web API from a .NET Client in this tutorial.What is your question?
Friday, May 4, 2018 8:40 PM -
User-1849651236 posted
I am trying to use the knowledge acquired from that tutorial to call APIs from my supplier's API server.
Their documentation for using the APIs says this:
"We apply JSON as the data collection format for communication through API using HTTP POST method. Each Request (Input) has to be formatted in JSON in a predefined manner before posting it to a dedicated URL. The resulting Response (Output) will also be displayed in a predefined format. The definition of Request and Response JSON format is defined precisely in the help of each API call."If I am requesting information from their server, not asking it to post or update anything on the server, would the "HTTP POST" method be used for that?
What would I use to format the request as JSON?
Thanks,
TonyFriday, May 4, 2018 8:51 PM -
User2053451246 posted
What would I use to format the request as JSON?The post of Json data will tell their API what you are trying to do, such as what it should return.Friday, May 4, 2018 8:57 PM -
User-1849651236 posted
The tutorial uses this to create a new product on the ProductsApp API server:
HttpResponseMessage response = await client.PostAsJsonAsync( // "api/products", product);
Would I use the same method to request something from my supplier's server?
Thanks,
TonyFriday, May 4, 2018 9:07 PM -
User475983607 posted
TGirgenti
I am trying to use the knowledge acquired from that tutorial to call APIs from my supplier's API server.
Their documentation for using the APIs says this:
"We apply JSON as the data collection format for communication through API using HTTP POST method. Each Request (Input) has to be formatted in JSON in a predefined manner before posting it to a dedicated URL. The resulting Response (Output) will also be displayed in a predefined format. The definition of Request and Response JSON format is defined precisely in the help of each API call."If I am requesting information from their server, not asking it to post or update anything on the server, would the "HTTP POST" method be used for that?
Thanks,
TonyKeep in mind that you're asking an ASP Support Forum how a 3rd party API works given a document snippet. I think ryanbesko is correct. It sound like there is one endpoint, one URL, for everything and everything is a POST. The content of the JSON message is what drives the behavior. I've worked in this type of RPC service model. Rather than HTTP GET to URL, you'll have a generic JSON object which contains defined sections; the action to invoke, the object type, the object name/values, and errors.
The API must have documentation that explains the expected JSON format for each type of behavior you're trying to invoke if this is indeed the model.
TGirgenti
What would I use to format the request as JSON?The tutorial in your link cover serializing JSON. Can you explain the problem you are having?
Friday, May 4, 2018 9:21 PM -
User-1849651236 posted
OK. I'll try to figure it out?
Friday, May 4, 2018 9:31 PM -
User753101303 posted
Hi,
Basic principles are the same ie ASP.NET takes care of the plumbing and you can receive .NET objects or post .NET objects to web services. Now the kind of object you'll get or post for a particular API should be part of your API provider documentation. For now it seems to me you have to check the documentation for the 3rd party service you are trying to use.
If you don't update or post (it's always best to tell what you are doing rather than what you are not doing ;-) ie assuming you just retrieve data it will be usually a GET request.
Saturday, May 5, 2018 11:53 AM -
User-1849651236 posted
PatriceSc,
I have access to all of the documentation provided by my 3rd party service. My question is not about them or their documentation.
I am just trying to figure out how to send a post request to their API system.
Thanks,
TonySunday, May 6, 2018 9:46 AM -
User753101303 posted
This tutorial should be enough to start. If you need further help it should be much easier to start from what happens when you try to use their service. You can get data but it fails when you are trying to send data back ?
As told earlier if you ou read data it should be a "GET" request (see GetProductAsync). As you told yourself what you shown is to create a new product and so you won't use the same to retrieve data (once again see "GetProductAsync" in this tutorial which uses GetAsync).Sunday, May 6, 2018 11:09 AM -
User-1849651236 posted
Thanks for your help PatriceSc.
I found a solution that works perfectly for me from here in the answer by Ivanzinho and it uses "POST" not "GET".
That is the answer to my question.
Thanks,
TonySunday, May 6, 2018 11:45 AM -
User753101303 posted
Great to see your issue is solved. Most often data retrieval is done using GET rather than POST but ultimately you have to use whatever is required by the API you are using.
Edit: or it seems you needed to post form fields to a web page rather than using a web API ? IMO always start with a short description of your actual need and if you tried something how it fails. It gives some context so that others can better understand which information you need.
Sunday, May 6, 2018 12:38 PM -
User-1849651236 posted
Oh. I see.
Thank you for your information and suggestions. There is more to asking for help than I thought. I will know better next time.
Thanks,
TonySunday, May 6, 2018 8:59 PM