<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Http request using &amp;quot;POST&amp;quot; method can't pass parameter in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573545#M73275</link>
    <description>&lt;P&gt;&lt;I&gt;[ FlexSim 21.2.4 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P id="isPasted"&gt;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.&lt;/P&gt;
 &lt;P&gt;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.&lt;/P&gt;
 &lt;PRE&gt;&lt;SPAN style="font-size: 8px;"&gt;string verb = "POST";
//this is the name or IP address of the server the request will be sent to
string server = &amp;nbsp;"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 ="?&amp;amp;reqCode=123";
string object = &amp;nbsp;"/services/genAgvTask";
//silent is a flag indicating whether you want any errors to be printed to FlexSim's system console (Debug &amp;gt; 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&lt;/SPAN&gt;&lt;/PRE&gt;
 &lt;P&gt;Another is Http.Request, my code like this,&lt;/P&gt;
 &lt;PRE&gt;&lt;SPAN style="font-size: 8px;"&gt;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&lt;/SPAN&gt;&lt;/PRE&gt;
 &lt;P id="isPasted"&gt;But it still can't work, the remote server still reports "The passed parameters is empty".&lt;/P&gt;
 &lt;P&gt;And then, I searched the docs(&lt;A id="isPasted"&gt;Post Method&lt;/A&gt;), 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?&lt;/P&gt;
 &lt;P&gt;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.&lt;/P&gt;
 &lt;P&gt;Thank you very much!&lt;/P&gt;
 &lt;P&gt;Yexioamu&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 22 Mar 2023 08:39:43 GMT</pubDate>
    <dc:creator>yexioamu</dc:creator>
    <dc:date>2023-03-22T08:39:43Z</dc:date>
    <item>
      <title>Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573545#M73275</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 21.2.4 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P id="isPasted"&gt;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.&lt;/P&gt;
 &lt;P&gt;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.&lt;/P&gt;
 &lt;PRE&gt;&lt;SPAN style="font-size: 8px;"&gt;string verb = "POST";
//this is the name or IP address of the server the request will be sent to
string server = &amp;nbsp;"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 ="?&amp;amp;reqCode=123";
string object = &amp;nbsp;"/services/genAgvTask";
//silent is a flag indicating whether you want any errors to be printed to FlexSim's system console (Debug &amp;gt; 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&lt;/SPAN&gt;&lt;/PRE&gt;
 &lt;P&gt;Another is Http.Request, my code like this,&lt;/P&gt;
 &lt;PRE&gt;&lt;SPAN style="font-size: 8px;"&gt;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&lt;/SPAN&gt;&lt;/PRE&gt;
 &lt;P id="isPasted"&gt;But it still can't work, the remote server still reports "The passed parameters is empty".&lt;/P&gt;
 &lt;P&gt;And then, I searched the docs(&lt;A id="isPasted"&gt;Post Method&lt;/A&gt;), 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?&lt;/P&gt;
 &lt;P&gt;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.&lt;/P&gt;
 &lt;P&gt;Thank you very much!&lt;/P&gt;
 &lt;P&gt;Yexioamu&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2023 08:39:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573545#M73275</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-22T08:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573546#M73276</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" id="isPasted" href="https://answers.flexsim.com/users/9/benjaminwilson.html" nodeid="9"&gt;@Ben Wilson&lt;/A&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/206/phil.b.html" nodeid="206"&gt;@Phil BoBo&lt;/A&gt; Dear Mr. Wilson and Mr.BoBo, I have read several questions that answered from you, But most of them is the "GET" method, so i still can't got the correct use method. Can you pay attention to this issue when you are free？Thank you very much!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2023 08:51:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573546#M73276</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-22T08:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573547#M73277</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Both methods look like they work fine. I just used &lt;A rel="noopener noreferrer" href="http://httpbin.org" target="_blank"&gt;httpbin.org&lt;/A&gt;, which mirrors back to you whatever you send it. I tested against their POST endpoint at &lt;A rel="noopener noreferrer" href="http://httpbin.org/post" target="_blank"&gt;httpbin.org/post&lt;/A&gt;.&lt;/P&gt;
 &lt;P&gt;Here are the results using Http.Request&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679485804486.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516197i63E91F6EF44AEA4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679485804486.png" alt="1679485804486.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;And using application command sendhttprequest&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679485943587.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516199i8B18D20C282847E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679485943587.png" alt="1679485943587.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;My sample model file is attached.&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/66112-http-post-test-v212.fsm" target="_blank"&gt;http_post_test_v21.2.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2023 11:57:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573547#M73277</guid>
      <dc:creator>Ben_WilsonADSK</dc:creator>
      <dc:date>2023-03-22T11:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573548#M73278</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;I tried your sample model, it work well, but my model is still not work, Maybe it is the problem of the remote server interface，I will check it with my R&amp;amp;D colleagues，Mr. Wilson, I owe you my best thanks！ I will reply you the follow-up results here in the next few days.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2023 12:41:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573548#M73278</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-22T12:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573549#M73279</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi, Mr.Wilson, i check it with my colleagues, Maybe the problem is my remote server requires header is 'application/json', but the header of this two method in flexsim(version 21.2.4) is '&lt;SPAN id="isPasted" style="color: rgb(0, 0, 0); font-family: "&gt;application/x-www-form-urlencoded&lt;/SPAN&gt;', I read your comments on this question(&lt;A id="isPasted"&gt;Sending Http.request for json content type&lt;/A&gt;), but i can't understand the &lt;A rel="nofollow" href="https://docs.flexsim.com/en/23.1/Reference/CodingInFlexSim/FlexScriptAPIReference/Http/Http.Request.html#Property-labelProperties"&gt;custom labelProperties property&lt;/A&gt; ，can it solve my problem? or any other solution?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Mar 2023 09:22:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573549#M73279</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-23T09:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573550#M73280</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/42692/yexioamu.html" nodeid="42692"&gt;@yexioamu&lt;/A&gt;, FlexSim version 22.1.0 added the ability to set custom request headers for Http.Request (&lt;A rel="noopener noreferrer" href="https://docs.flexsim.com/en/Reference/CodingInFlexSim/FlexScriptAPIReference/Http/Http.Request.html#Property-headers" target="_blank"&gt;documentation&lt;/A&gt;, &lt;A rel="noopener noreferrer" href="https://docs.flexsim.com/en/Reference/ReleaseNotesAndHistory/ReleaseNotesAndHistory.html#22-1-0" target="_blank"&gt;release notes&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;In the attached example you can see the request.headers setter, where I specify JSON, and in the response that header is mirrored back.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679575905854.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516201i826301CE489B60FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679575905854.png" alt="1679575905854.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You would need to upgrade your FlexSim version to version 22.1 or higher take advantage of this new feature.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/89735-http-post-test-v221.fsm" target="_blank"&gt;http_post_test_v22.1.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Mar 2023 12:53:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573550#M73280</guid>
      <dc:creator>Ben_WilsonADSK</dc:creator>
      <dc:date>2023-03-23T12:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573551#M73281</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank for your answer, i tried the request.headers you suggested in the version 23.05 by using PF, it works well! But due to my company software purchase policy, i can't upgrade my FlexSim version quickly, does it possible that achieve it in version 21.2.4, or can i achieve it by using DLL function? If it is possible, can i get some references from anywhere?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:46:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573551#M73281</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-23T13:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573552#M73282</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Yes, if you want to use C++, you can use the &lt;A href="https://docs.flexsim.com/en/21.2/Reference/DeveloperAdvancedUser/ModuleSDK/QuickStart/QuickStart.html#adding"&gt;21.2 Module SDK&lt;/A&gt; or the FlexSim DLL Maker (in the 'Modules' section of &lt;A href="https://account.flexsim.com/downloads/"&gt;https://account.flexsim.com/downloads/&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;For an example of sending HTTP requests, see: &lt;A href="https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttp-sessions-overview"&gt;https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttp-sessions-overview&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:56:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573552#M73282</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2023-03-23T13:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573553#M73283</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thanks for your answer! i will try it. thanks again!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Mar 2023 14:23:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573553#M73283</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-23T14:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573554#M73284</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P id="isPasted"&gt;Hi, BoBo, i am tring the dll maker, i use the winhttp method you suggested in a pure cpp project at first, and it work well.&lt;/P&gt;
 &lt;P&gt;Then, i create a function named HttpRequest in the mydll.cpp of the dllmaker, and then use const char* variables to put the parameters from flexsim user command, but it seems like the order of the parstr is disordered, and some parameters is repeated, i am confused about it.&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="the-screen-shot-of-first-dll.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516203iC4646DE5FF72D04E/image-size/large?v=v2&amp;amp;px=999" role="button" title="the-screen-shot-of-first-dll.png" alt="the-screen-shot-of-first-dll.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;and then, i use string to put the parameters from flexsim and transform to wchar_t* so that the winhttp method can accept, but it just display the first letter of the value, and iti is also work well in the pure cpp project. i am confused about it too.&lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="the-screen-shot-of-second-dll.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516204i92FA12B405E7751B/image-size/large?v=v2&amp;amp;px=999" role="button" title="the-screen-shot-of-second-dll.png" alt="the-screen-shot-of-second-dll.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;My code in flexsim is next, command2 is a user command.&lt;/P&gt;
 &lt;PRE style="line-height: 1;"&gt;&lt;SPAN style="font-size: 8px;"&gt;string server = &amp;nbsp;"xx.xx.xx.xx";

string verb = "POST";

string path = &amp;nbsp;"/services/genAgvTask";

string headers = "Content-Type: application/json";

string data ="{\"reqCode\":\"123\"}";

command2(server, verb, path, headers, data);&lt;/SPAN&gt;&lt;/PRE&gt;
 &lt;P&gt;Could you help me? Thank you!&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/66228-attachment.zip" target="_blank"&gt;attachment.zip&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Mar 2023 11:32:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573554#M73284</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-24T11:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573555#M73285</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The FlexSim Support answer to your question is to simply use the latest FlexSim version. We've already solved this issue.&lt;/P&gt;&lt;P&gt;If you want detailed help in resolving this in an older version, contact your local distributor for direct support. &lt;A rel="user" href="https://answers.flexsim.com/users/17334/support.html" nodeid="17334"&gt;@CSN&lt;/A&gt; &lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Mar 2023 13:54:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573555#M73285</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2023-03-24T13:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Http request using "POST" method can't pass parameter</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573556#M73286</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 What a pity for me，whatever，I am appreciated for your answers，thanks again
&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Mar 2023 14:17:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/http-request-using-quot-post-quot-method-can-t-pass-parameter/m-p/13573556#M73286</guid>
      <dc:creator>yexioamu</dc:creator>
      <dc:date>2023-03-24T14:17:02Z</dc:date>
    </item>
  </channel>
</rss>

