PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Details of usable codes
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
WebserviceWriteHTTPCode (Function)
In french: WebserviceEcritCodeHTTP
AjaxNot available
Fills the HTTP code that will be returned at the end of execution of REST Webservice function. This function is used to specify some categories of return codes:
  • Codes 2xx to manage the Success of function execution.
  • Codes 3xx to manage the Redirection of a function.
  • Codes 4xx to manage a Client error.
  • Codes 5xx to manage a Server error.
Example
// Indicates the client creation : 201 Created
WebserviceWriteHTTPCode(201, "https://server/Client/" + Client.id)
// And returns the client details
RESULT sClient

// Indicates the absence of response : 204 No Content
WebserviceWriteHTTPCode(204)
// And returns no response
RESULT ""

// Accepts a JSON or XML content
SWITCH WebserviceReadMIMEType()
CASE "application/json"
// Processes the JSON case
...
CASE "application/xml"
// Processes the XML case
...
OTHER CASE
// Processes the other cases (triggers an error)
// Indicates that the format of received data is in unknown :
// 415 Unsupported Media Type
WebserviceWriteHTTPCode(415, sError)
RETURN
END
Syntax
WebserviceWriteHTTPCode(<HTTP Code> [, <Additional information>])
<HTTP Code>: Integer
HTTP code returned by the call to the Webservice. The following codes are accepted:
  • Codes 2xx (Success)
  • Codes 3xx (Redirection)
  • Codes 4xx (Client error)
  • Codes 5xx (Server error)
See Details of usable codes for more details.
<Additional information>: Optional character string
Additional information required by some return codes. The affected return codes are as follows:
  • Code 201 (Created) : optional information : Address of added information.
  • Code 301 (Moved Permanently) : mandatory information : Redirection address.
  • Code 302 (Moved Temporarily) : mandatory information : Redirection address.
  • Codes 4xx and 5xx : mandatory information : Text of error returned to the client. The text will be converted into UTF-8.
Remarks
  • This function is useful if the call to the REST Webservice must return a code other than 200.
  • The WEBDEV application server automatically generates a code 4xx or 5xx for the detected errors.
  • This function is only available during the call to a function that processes a request of a REST Webservice. In the other cases, the function triggers an error.

Details of usable codes

The following HTTP codes returned by the call to the Webservice are accepted:
  • Codes 2xx (Success)
    • 200 OK
    • 201 Created
    • 204 No Content
  • Codes 3xx (Redirection)
    • 301 Moved Permanently
    • 302 Moved Temporarily
  • Codes 4xx (Client error)
    • 400 Bad Request
    • 401 Unauthorized
    • 403 Forbidden
    • 404 Not Found
    • 405 Method Not Allowed
    • 406 Not Acceptable
    • 415 Unsupported Media Type
  • Codes 5xx (Server error)
    • 500 Internal Server Error
    • 501 Not Implemented
    • 503 Service Unavailable
Component : wd240awws.dll
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment