Hi,
I want to post an excel file selected from the file picker control to an external website using the #prim_web.Httprequest.
There are examples in the manual and xDemoWebWeather, but both are examples of the Get method and I couldn't find an example of the Post method.
Please let me know if anyone has an example.
In particular, I would like to know how to overwrite headers and create form data.
Regards,
Taku Izumi
Is there an example of Post method of #Prim_web.Httprequest?
-
- Posts: 36
- Joined: Thu Dec 15, 2016 2:03 pm
Re: Is there an example of Post method of #Prim_web.Httprequest?
Ohayou Taku Izumi!
There is an example web page XDEMO_126 which makes a PUT instead of a POST, but the concept should be the same. I created this example based on that to access a url in jsontest.com
There is an example web page XDEMO_126 which makes a PUT instead of a POST, but the concept should be the same. I created this example based on that to access a url in jsontest.com
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)
Define_Com Class(#PRIM_LIST) Name(#List) ColumnHeaderHeight(48) ColumnLines(False) DisplayPosition(1) Height(388) Left(32) Parent(#COM_OWNER) RowHeight(48) TabPosition(1) Top(37) Width(1161)
Define_Com Class(#PRIM_LIST.String) Name(#ListColumn1) ColumnWidth(1) DisplayPosition(1) Parent(#List) SortOnClick(True) Source(#STD_NVARC) CellWidth(0) ColumnUnits(Proportion)
Define_Com Class(#STD_INT) Name(#HttpStatus)
Evtroutine Handling(#Com_owner.Initialize)
#COM_OWNER.TestAPost
Endroutine
Mthroutine Name(TestAPost)
* Define_Com Class(#Prim_Web.HttpRequest) Name(#PostTest) Url("http://ip.jsontest.com/") Method(POST)
* http://validate.jsontest.com/?json={"key":"value"}
Define_Com Class(#Prim_Web.HttpRequest) Name(#PostTest) Url('http://validate.jsontest.com/?json={"three":"san"}') Method(POST)
Define_Com Class(#PRIM_WEB.Json) Name(#Json)
Define_Com Class(#prim_web.JsonElement) Name(#JRoot_Element) Reference(*Dynamic)
Define_Com Class(#PRIM_WEB.JsonObject) Name(#JsonObject) Reference(*Dynamic)
#JsonObject <= #Json.CreateRootObject
#JsonObject.InsertString Key("one") String("ichi")
#JsonObject.InsertString Key("two") String("ni")
#PostTest.Content := #Json
#PostTest.ExecuteAsync
Evtroutine Handling(#PostTest.Completed)
#STD_NVARC := ('Completed')
Add_Entry To_List(#List)
#HttpStatus := #PostTest.Response.StatusCode
#Json := #PostTest.Response.Content
#JRoot_Element <= #Json.RootItem
#STD_NVARC := #HttpStatus.AsString
Add_Entry To_List(#List)
If (#HttpStatus = 200)
#STD_NVARC := #PostTest.Response.Content.Text
Add_Entry To_List(#List)
Else
#STD_NVARC := #PostTest.Response.StatusText
Add_Entry To_List(#List)
Endif
Endroutine
Evtroutine Handling(#PostTest.Failed)
#Sys_web.Alert Caption("Post Failed")
Endroutine
Endroutine
End_Com
-
- Posts: 36
- Joined: Thu Dec 15, 2016 2:03 pm
Re: Is there an example of Post method of #Prim_web.Httprequest?
Hi Dino,
Sorry I couldn't get back to you sooner.
I will try to POST a form-data based on the sample.
Arigato Gozaimashita
,
Taku Izumi
Sorry I couldn't get back to you sooner.
I will try to POST a form-data based on the sample.
Arigato Gozaimashita

Taku Izumi