Are there any http request samples in c/c++, c#, java?
AnsweredHello. I want to send http request to VMS from the another device. For example:
string sendData ="http://admin:pass@192.168.1.222:7001/api/createEvent?source=1&caption=2&description=3";
Stream requestStream = null;
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpWebRequest.ContentLength = sendData.Length;
requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(sendData, 0, sendData.Length);
How can I send or receive requests from another device? please help
-
Hi Nodirbek Baratov,
depending on your task, different instruments can be used to send API requests. Each software language has third-party library allowing you to generate HTTP requests. Based on your code snippet you're doing it fundamentally wrong:
1. You sending POST requests, while server API states that /api/createEvent should be a GET request.
2. You don't need to write "http://admin:pass@192.168.1.222:7001/api/createEvent?source=1&caption=2&description=3" into request body, this is wrong. This string is the url string.
How can I send or receive requests from another device? please help
Could you please clarify your scenario? Sending and receiving requests are different things and covers different scenarios and sending API requests c/c++, c#, java usually isn't the most simple thing to do. Usually it's enough to use script languages like python for this.
0
Please sign in to leave a comment.
Comments
1 comment