Hi, I have a question about Http Request. When I want to request data from a remote server, the interface of the server only can be requested by "POST" method. I used two functions that I can find in this forum website.
One is applicationcommand("sendhttprequest", verb, server, object, data, silent, result), the value of verb is "POST", server is the IP of the remote server, object is the path of the interface, when I run the model, I can see the call record of the interface in the remote server, but it reports "The passed parameters is empty", It seems like the data is not passed.
string verb = "POST";
//this is the name or IP address of the server the request will be sent to
string server = "xx.xxx.xxx.xxx"; //it is the IP of the remote server
//object represents the rest of the URL after the server name
string data ="?&reqCode=123";
string object = "/services/genAgvTask";
//silent is a flag indicating whether you want any errors to be printed to FlexSim's system console (Debug > System Console)
int silent = 1;
//specify a text node in the tree where the server's response will be written
treenode result = node("/Tools/result", model());
//send the HTTP request
applicationcommand("sendhttprequest", verb, server, object, data, silent, result
Another is Http.Request, my code like this,
Http.Request request = Http.Request("IP/services/genAgvTask");
request.method = Http.Method.Post;
request.data = "reqCode=123";
request.useSSL = 0;
Http.Response response = request.sendAndWait();
string json = response.value;
Map map = JSON.parse(json
But it still can't work, the remote server still reports "The passed parameters is empty".
And then, I searched the docs(Post Method), it show that the description of the "Post" method is "Method to create or replace a target resource with specified data", can this method request data from server?
I'm so confused about this question a few weeks, can you give me some suggestions, and offer a example about request data by using "POST" method.
Thank you very much!
Yexioamu