Submit
Description
Sends the data to the server via the HTTP POST method and then gets
the response body from the server.
It is not recommended to use this method to process large data (20
MB or 100,000 data rows can be considered as large data based on our
tests).
Applies to
RESTClient object
Syntax
|
1 |
objectname.Submit(string urlName, ref string response, DWControl dwObject{, boolean format}) |
|
1 |
objectname.Submit(string urlName, ref string response, DWControl dwObject {,DWBuffer dwbuffer}, boolean changedonly, boolean format) |
|
1 |
objectname.Submit(string urlName, ref string response, DWControl dwObject, boolean primarydata, boolean filterdata, boolean deletedata, boolean dwcdata {, boolean format}) |
|
1 |
objectname.Submit(string urlName, ref string response, DWControl dwObject, DWBuffer dwbuffer{,long startrow{, long endrow{, long startcol{, long endcol}}}} {, boolean format}) |
|
1 |
objectname.Submit(string urlName, ref string response, ref JsonPackage package) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the RESTClient object. |
|
urlName |
The URL indicating where the data will be |
|
response |
The content of the server response. If RESTClient failed to send request or server provides no |
|
dwObject |
The DataWindow control, DataStore, or DataWindowChild |
|
primarydata |
A boolean indicating whether to export and submit the data
|
|
filterdata |
A boolean indicating whether to export and submit the data
|
|
deletedata |
A boolean indicating whether to export and submit the data
|
|
dwcdata |
A boolean specifying whether to export the DataWindowChild
|
|
dwbuffer |
A value of the dwBuffer enumerated datatype identifying If not specified, all of the DataWindow buffers will be |
|
startrow (optional) |
A long value specifying the start row in the dwbuffer DataWindow buffer. The default is 1. If it is 0 or negative, 1 is used. |
|
endrow (optional) |
A long value specifying the end row in the dwbuffer DataWindow buffer. The default is the rest of the rows. If it is 0 or negative, it indicates the rest of rows. |
|
startcol (optional) |
A long value specifying the start column in the dwbuffer DataWindow buffer. The default is 1. If it is 0 or negative, 1 is used. |
|
endcol (optional) |
A long value specifying the end column in the dwbuffer DataWindow buffer. The default is the rest of the columns. If it is 0 or negative, it indicates the rest of columns. |
|
changedonly |
A boolean specifying the changing flag.
|
|
format (optional) |
A boolean specifying the JSON format.
See the section called “Supported JSON formats” in Application Techniques for details about the JSON |
|
package |
A reference to JsonPackage object whose data will be |
Return value
Integer. Returns 1 if the function succeeds and a negative value if
an error occurs. If any argument’s value is null, the method returns
null.
1 — Success
-1 — General error
-2 — Invalid URL
-3 — Cannot connect to the Internet
-4 — Timeout
-6 — Failed to export JSON
-7 — Failed to decompress data
-10 — The token is invalid or has expired
-14 — Code conversion failed
-15 — Unsupported character set
Examples
The following example demonstrates the usage of syntax 1:
Submit(string urlName, ref string response, DWControl dwObject{, boolean
format}).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
String ls_P025_ResponseBody Integer li_P025_SendReturn RestClient lrc_P025 lrc_P025 = Create RestClient lrc_P025.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" ) lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") //Modifies the data in dw_Data If dw_Data.GetRow() > 0 Then dw_Data.SetItem(dw_Data.GetRow(), 2, "Test submit") //.... End If //Uses the DataWindow JSON //Server determines whether to update according to the data state //DataWindow column name and type must match with that of server li_P025_SendReturn = lrc_P025.submit ("https://demo.appeon.com/PB/webapi_client/department/updateByJson",ls_P025_Responsebody, dw_Data,True) If li_P025_SendReturn <> 1 Or lrc_P025.GetResponseStatusCode() <> 200 Then //Checks if any error information End If //Finds out if data is updated via https://demo.appeon.com/PB/webapi_client/api/department/retrieve lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") |
The following example submits the data of the DataWindow primary
buffer using syntax 2: Submit(string urlName, ref string response,
DWControl dwObject {,DWBuffer dwbuffer}, boolean changedonly, boolean
format).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
String ls_P025_ResponseBody Integer li_P025_SendReturn RestClient lrc_P025 lrc_P025 = Create RestClient lrc_P025.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" ) lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") //Modifies the data in dw_Data If dw_Data.GetRow() > 0 Then dw_Data.SetItem(dw_Data.GetRow(), 2, "Test submit primary") //.... End If //Uses the DataWindow JSON //Server determines whether to update according to the data state //DataWindow column name and type must match with that of server li_P025_SendReturn = lrc_P025.Submit("https://demo.appeon.com/PB/webapi_client/department/updateByJson",ls_P025_Responsebody, dw_Data,Primary!, True, True) If li_P025_SendReturn <> 1 Or lrc_P025.GetResponseStatusCode() <> 200 Then //Checks if any error information End If //Finds out if data is updated via https://demo.appeon.com/PB/webapi_client/api/department/retrieve lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") |
The following example submits the data of the DataWindow delete
buffer using syntax 3: Submit(string urlName, ref string response,
DWControl dwObject, boolean primarydata, boolean filterdata, boolean
deletedata, boolean dwcdata {, boolean format}).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
String ls_P025_ResponseBody Integer li_P025_SendReturn RestClient lrc_P025 lrc_P025 = Create RestClient lrc_P025.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" ) lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") //Modifies the data in dw_Data If dw_Data.RowCount() > 0 Then dw_Data.DeleteRow( dw_Data.RowCount()) //.... End If //Uses the DataWindow JSON //Server determines whether to update according to the data state //DataWindow column name and type must match with that of server li_P025_SendReturn = lrc_P025.Submit("https://demo.appeon.com/PB/webapi_client/department/updateByJson", ls_P025_Responsebody, dw_Data, False, False, True, False, True) If li_P025_SendReturn <> 1 Or lrc_P025.GetResponseStatusCode() <> 200 Then //Checks if any error information End If //Finds out if data is deleted via https://demo.appeon.com/PB/webapi_client/api/department/retrieve lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") |
The following example submits the data of the specified row and
column using syntax 4: Submit(string urlName, ref string response,
DWControl dwObject, DWBuffer dwbuffer{,long startrow{, long endrow{, long
startcol{, long endcol}}}} {, boolean format}).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
String ls_P025_ResponseBody Integer li_P025_SendReturn RestClient lrc_P025 lrc_P025 = Create RestClient lrc_P025.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" ) //Retrieves data for dw_Data lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") //Modifies the data in dw_Data If dw_Data.GetRow() > 0 Then dw_Data.SetItem( dw_Data.GetRow(), 2,"Submit row col"+String(rand(100))) dw_Data.SetItem( dw_Data.GetRow(), 3,rand(1000)) //.... End If //Uses the DataWindow JSON //Server determines whether to update according to the data state //DataWindow column name and type must match with that of server li_P025_SendReturn = lrc_P025.Submit("https://demo.appeon.com/PB/webapi_client/department/updateByJson", ls_P025_Responsebody, dw_Data, Primary!,1, 2, 1, 2) If li_P025_SendReturn <> 1 Or lrc_P025.GetResponseStatusCode() <> 200 Then //checke the failed information End If //Finds out if data of column 2 is updated via https://demo.appeon.com/PB/webapi_client/api/department/retrieve lrc_P025.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") |
The following example submits data via JSONPackage object and token
authentication using syntax 5: Submit(string urlName, ref string response,
ref JsonPackage package).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
JsonPackage ljpk_submit RestClient lrc_JPK_Submit String ls_P017_Token String ls_Submit_Responsebody Integer li_JsonpackageSetValueReturn Integer li_P017_GetTokenReturn Integer li_SubmitReturn ljpk_submit = Create JsonPackage lrc_JPK_Submit = Create RestClient //Sets the token parameters TokenRequest ltreq_P017_Appeon ltreq_P017_Appeon.tokenlocation = "https://demo.appeon.com/pb/identityserver/connect/token" ltreq_P017_Appeon.method = "post" ltreq_P017_Appeon.GrantType = "password" ltreq_P017_Appeon.ClientId = "P0VRQ-ddHn/WWd6lcCNJbaO9ny-JCNHirDJkHNgZ0-M=" ltreq_P017_Appeon.ClientSecret = "K7gNU3sdo-OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=" ltreq_P017_Appeon.UserName = "TestUser" ltreq_P017_Appeon.PassWord = "TestPassword" //Gets token via RESTClient li_P017_GetTokenReturn = lrc_JPK_Submit.GetOauthtoken( ltreq_P017_Appeon, ls_P017_Token) If li_P017_GetTokenReturn = 1 Then lrc_JPK_Submit.SetRequestHeaders( "Content-Type:application/json;charset=UTF-8~r~nAccept-Encoding:gzip" ) lrc_JPK_Submit.SetOauthToken( ls_P017_Token ) //Sets the authentication lrc_JPK_Submit.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") //Modifies data If dw_Data.GetRow() >0 Then dw_Data.SetItem(dw_Data.GetRow(),2,"Test submit from jsonpackage"+String(rand(100))) //... End If //Value of JSONPackage comes from dw_Data li_JsonpackageSetValueReturn = ljpk_submit.setvalue( "AppeonJsonPackageKey", dw_Data, True) //Submits the DataWindow data to server //Requires token authentication //DataWindow column name and type must match with that of server li_SubmitReturn = lrc_JPK_Submit.Submit( "https://demo.appeon.com/PB/webapi_client/identity/department/UpdateByJsonPackage",ls_Submit_Responsebody, ljpk_submit) If li_SubmitReturn <> 1 Or lrc_JPK_Submit.GetResponseStatusCode() <> 200 Then //Checks if any error information and checks the submit parameter: ls_Submit_Responsebody End If //Finds out if data is updated via https://demo.appeon.com/PB/webapi_client/api/department/retrieve lrc_JPK_Submit.Retrieve( dw_Data, "https://demo.appeon.com/PB/webapi_client/api/department/retrieve") End If |