PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Properties specific to the description of restRequest variables
  • Managing redirections
  • HTTP cookies
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
restRequest (Type of variable)
In french: restRequête
The restRequest type is used to define the advanced characteristics of a REST request. The characteristics of the REST request can be defined and changed using different WLanguage properties.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
cMyRequest is httpRequest
cMyRequest.URL = "http://www.windev.com"
cMyResponse is httpResponse = RESTSend(cMyRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(cMyResponse.Content)
END
Remarks

Properties specific to the description of restRequest variables

The following properties can be used to handle a REST request:
Property nameType usedEffect
AuthTokenAuthToken variableToken for accessing a Webservice that will be used in case of authentication via the OAuth 2.0 protocol. This access token is retrieved by AuthIdentify.
The access token is automatically passed to the access_token parameter on the URL. If the parameter must be different, the URL to run must be built by yourself.
WEBDEV - Browser code Not available.
ClientCertificateString or bufferCorresponds to:
  • a character string with an access path to the .p12 file that contains the certificate to attach to the request. The certificate will be automatically loaded taking into account:
    • the certificate in the executable library (if it has been integrated into the application),
    • the certificate at the specified location on disk (if the certificate has not been integrated into the executable library).
  • a buffer with the certificate (fLoadBuffer).
If this property corresponds to an empty string (""), the default certificate is reset to "<None>".
ClientCertificatePasswordCharacter stringPassword associated with the client certificate (empty string by default)
ConnectionTimeoutIntegerMaximum timeout for the connection expressed in milliseconds (20 seconds by default, which means 20000 milliseconds). This property can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., '20s' ou '20000ms').
The connection fails if it cannot be established after this timeout (RESTSend will return an error, in the restResponse result variable).
WEBDEV - Browser code Not available.
ContentBufferMessage to send to the server. This property is taken into account only if the sending method (Method property) allows it.
The message to send must comply with the HTTP protocol used. By default, if this property is specified and if it is not empty, the method used is a POST request ; otherwise, it is a GET request.
ContentTypeCharacter stringType of content of the message to send to the server. This property is taken into account only if the sending method (Method property) allows it.
By default, the message type corresponds to: "application/x-www-form-urlencoded".
However, you have the ability to use any value, for example: "text/xml", "application/javascript", "application/json", "application/xml", "image/jpeg", ...
To send rough data that will be read at once by the WEBDEV application server, use the following types:
  • "application/octet-stream".
  • "text/xml".
DestinationCharacter stringFull path of the query result backup file.
WEBDEV - Browser code Not available.
DownloadProgresshttpProgress variableData reception progress notification.
HeaderAssociative array of character stringsKey/Value set of headers to send.
Example for using this property:
cMyRequest is httpRequest
 
cMyRequest.Header["Authorization"] = ...
" WSSE profile=""UsernameToken"""
cMyRequest.Header["X-WSSE"] = ...
"UsernameToken Username=blahblah "
cMyRequest.Header["Cache-Control"] = " no-cache"
IgnoreErrorInteger constantSpecifies the ignored errors. Corresponds to a constant or to a combination of constants:
  • httpIgnoreInvalidCertificate: The certificate is ignored.
  • httpIgnoreInvalidCertificateName: The site name specified in the certificate is ignored.
  • httpIgnoreExpiredCertificate: The certificate date is ignored.
  • httpIgnoreRedirection: The redirection to a page is ignored.
  • httpIgnoreRedirectToHTTP: The redirection to a non-secure server is allowed.
  • httpIgnoreRedirectToHTTPS: The redirection to a secure server is allowed.
WEBDEV - Browser code Not available.
MaxDownloadRateIntegerMaximum data download speed in kilobytes per second. This speed is given for information only.
0 (default value) means that this speed is not limited.
WEBDEV - Browser code Not available.
MaxUploadRateIntegerMaximum data upload speed in kilobytes per second. This speed is given for information only.
0 (default value) means that this speed is not limited.
WEBDEV - Browser code Not available.
MethodInteger constantHTTP method used:
  • httpCopy: COPY method.
  • httpDelete: DELETE method.
  • httpGet: GET method.
  • httpHead: HEAD method.
  • httpLock: Lock method (WebDAV protocol).
  • httpMkCol: MkCol method (WebDAV protocol).
  • httpMove: Move method (WebDAV protocol).
  • httpPatch: PATCH method.
  • httpPost: POST method.
  • httpPropFind: PROPFIND method (WebDAV protocol).
  • httpPropPatch: PROPPATCH method (WebDAV protocol).
  • httpPut: PUT method.
  • httpUnlock: Unlock method (WebDAV protocol).
If the Content property is not empty, the httpPost method is used by default. Otherwise, the httpGet method is used.
PasswordCharacter stringPassword associated with the username (empty string by default). Used to access a page with a protected URL. Caution: The password is not encrypted when it is sent over the Internet.
Remark: If the UserName and Password properties are specified, the corresponding "Authorization:Basic" header is automatically generated in the request header.
ProcedureTraceProcedureName of the WLanguage procedure used to identify the data and headers that have been sent. This procedure has the following format:
PROCEDURE <Procedure name>(<InfoType> is int,
<Data> is Buffer)
where:
  • <InfoType> is an integer constant that corresponds to the type of data being traced:
    • httpTraceDataSent: Data sent.
    • httpTraceDataReceived: Data received.
    • httpTraceHeaderSent: Header sent.
    • httpTraceHeaderReceived: Header received.
  • <Data> is a buffer that contains the information.
Example of procedure:
PROCEDURE ProcTrace(nInfoType is int, ...
bufByData is Buffer)
SWITCH nInfoType
CASE httpTraceHeaderSent
Trace("Header: ", ...
UTF8ToString(bufByData))
CASE httpTraceDataSent:
Trace("Data: ", ...
bufByData)
CASE httpTraceHeaderReceived:
Trace("Header received: ", ...
UTF8ToString(bufByData))
CASE httpTraceDataReceived:
Trace("Data received: ", ...
bufByData)
END
WEBDEV - Browser code Not available.
WEBDEV - Browser code ResponseRawContent
BooleanIndicates whether the Content property corresponds to the raw content:
  • True: the Content property corresponds to a buffer. No modification is performed.
  • False (Default value): the content is modified by the browser. In particular, UTF-8 text is automatically decoded. the Content property returns the result as a string.
TimeoutIntegerMaximum response timeout (in milliseconds). This property can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).
This property is set to 20 seconds by default.
Remark: The timeout defined by HTTPTimeOut has no influence on this property.
WEBDEV - Browser code Not available.
UploadProgresshttpProgress variableNotification of progress status when uploading POST data.
URLCharacter stringAddress of server to contact (URL address).
This URL can contain:
  • the port number for connecting to the server.
    The default value is 80 in HTTP (corresponds to a server of Web pages) and 443 in HTTPS. To specify a port number, use the following format: "<Server URL>:<Port #>". For example: http://www.windev.com:80.
  • additional parameters. These parameters can be used to perform a search or to fill a form. For example, to find "windev" on "http://www.google.com", the URL to contact will be: "http://www.google.com/search?q=windev".
Remarks:
  • To specify both the port number and additional parameters, use the following format: "<Server URL>:<Port #>/<Additional parameters>".
  • To perform a secure transaction, the URL must start with "https://". In this case, the management mode of requests is always performed by Internet Explorer (for more details, see HTTPParameter).
UserCharacter stringName used to access a page with a protected URL (empty string by default). This name is used to identify the user.
Remark: If the UserName and Password properties are specified, the corresponding "Authorization:Basic" header is automatically generated in the request header.
UserAgentCharacter stringIdentifies the client. The default value is "PC SOFT Framework".
The content of the response may depend on the user agent (for example, a request performed from a Mobile device and a request performed from a PC browser may require different pages). In this case, for more details, see the documentation of user agent.
WEBDEV - Browser code Not available.
VersionHTTPInteger constantHTTP version used by the server:
  • httpVersion2: HTTP version 2.0. If the server does not support this version, an older version is used.
  • httpVersion2Only: Forces HTTP version 2.0: if the server does not support this version, a fatal error is displayed.
  • httpVersion1_1: HTTP version 1.1.
  • httpVersion1_0: HTTP version 1.0.
  • httpVersionDefault: HTTP version 1.0.
VersionSSLInteger constantSSL version used:
  • ProtocolDefault: Default protocol (TLS 1.2).
  • ProtocolTLS1: TLS1 protocol.
  • ProtocolTLS1_1: TLS1.1 protocol.
  • ProtocolTLS1_2: TLS1.2 protocol.
WEBDEV - Browser code Not available.

Managing redirections

Redirections are supported by default. To ignore redirections, use the httpIgnoreRedirection constant in the IgnoreError property.
WEBDEV - Server codeAjax

HTTP cookies

Cookies received in response to a call to RESTSend are stored while waiting for a subsequent call to RESTSend on the same domain: the restRequest variable is updated.
For more details, see HTTPCookieManage.
Minimum version required
  • Version 20
This page is also available for…
Comments
Video httpput
PROPAGANDA AULA 2025 RESTREQUEST
https://youtu.be/cJZm-WrAPgM
AULA COMPLETA 2025 RESREQUEST
https://youtu.be/d3zULOtHQjs
https://windevdesenvolvimento.blogspot.com/2019/02/dicas-2025-windev-mobile-webservice-021_23.html
// BTN_ALTERA_httpPut
solicitacao_http is restRequest
URL is string="http://nots-amarildo/empresa/{nEmpresaId}"
URL = Replace(URL,"{nEmpresaId}","2")
solicitacao_http..URL=URL
solicitacao_http..ContentType="application/json"
solicitacao_http..Method=httpPut
solicitacao_http..Content=[
{
"razao_social"
:
"ALTERADO1205"
}
]
resposta_http is restResponse = RESTSend(solicitacao_http)
EDT_RETORNO=resposta_http..Content
amarildo
23 Feb. 2019
Video RestREquest


https://youtu.be/G7oY3hd7Jo0

https://windevdesenvolvimento.blogspot.com/2019/02/dicas-2023-windev-mobile-webservice-019.html

solicitacao_http is restRequest
sUrl is string="http://localhost/empresa/{nEmpresaid}"
sUrl=Replace(sUrl,"{nEmpresaid}","2")
solicitacao_http..URL=sUrl
solicitacao_http..Method=httpGet
resposta_http is restResponse = RESTSend(solicitacao_http)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
EDT_RETORNO=resposta_http..Content
END

amarildo
22 Feb. 2019
Video Restquest
https://youtu.be/VvMa-5kUZkQ

https://windevdesenvolvimento.blogspot.com/2019/02/dicas-2022-windev-mobile-webservice-018.html

solicitacao_http is restRequest
solicitacao_http..URL="http://nots-amarildo/empresa"
solicitacao_http..Method=httpGet
resposta_http is restResponse = RESTSend(solicitacao_http)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
EDT_RETORNO=resposta_http..Content
END
amarildo
20 Feb. 2019