ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Web services
  • Code details
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
WebserviceWriteHTTPCode (Function)
In french: WebserviceEcritCodeHTTP
AjaxNot available
Specifies the HTTP code that will be returned at the end of the execution of the REST web service function. This function classifies return codes as follows:
  • 2xx codes for Successful responses.
  • 3xx codes for Redirections.
  • 4xx codes for Client errors.
  • 5xx codes for Server errors.
Example
// Indicates the client creation: 201 Created
WebserviceWriteHTTPCode(201, "https://server/Client/" + Client.id)
// And returns the client details
RETURN sClient

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

// 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 web service. The following codes are supported:
  • 2xx codes (Successful responses).
  • 3xx codes (Redirections).
  • 4xx codes (Client errors).
  • 5xx codes (Server errors).
For more details, see Code details.
<Additional information>: Optional character string
Additional information required by some return codes. The return codes are as follows:
  • 201 (Created): optional information: Address of added information.
  • 301 (Moved Permanently): required information: Redirection address.
  • 302 (Found): required information: Redirection address.
  • 4xx and 5xx: required information: Text of the error returned to the client. The text will be converted to UTF-8.
Remarks
  • This function is useful if the call to the REST web service must return a code other than 200.
  • WEBDEV Application Server automatically generates a 4xx or 5xx code for the errors it detects.
  • This function is only available when calling a function that processes a REST web service request. In all other cases, the function causes an error.

Code details

The HTTP codes currently supported are:
  • 1xx codes
    • 100 Continue
    • 101 Switching Protocols
    • 102 Processing
    • 103 Early Hints
  • 2xx codes (Successful responses)
    • 200 OK
    • 201 Created
    • 202 Accepted
    • 203 Non-Authoritative Information
    • 204 No Content
    • 205 Reset Content
    • 206 Partial Content
    • 207 Multi-Status
    • 208 Already Reported
    • 226 IM Used
  • 3xx codes (Redirections)
    • 300 Multiple Choices
    • 301 Moved Permanently
    • 302 Found
    • 303 See Other
    • 304 Not Modified
    • 305 Use Proxy
    • 307 Temporary Redirect
    • 308 Permanent Redirect
  • 4xx codes (Client errors)
    • 400 Bad Request
    • 401 Unauthorized
    • 402 Payment Required
    • 403 Forbidden
    • 404 Not Found
    • 405 Method Not Allowed
    • 406 Not Acceptable
    • 407 Proxy Authentication Required
    • 408 Request Time-out
    • 409 Conflict
    • 410 Gone
    • 411 Length Required
    • 412 Precondition Failed
    • 413 Request Entity Too Large
    • 414 Request-URI Too Long
    • 415 Unsupported Media Type
    • 416 Requested range unsatisfiable
    • 417 Expectation failed
    • 421 Bad mapping / Misdirected Request
    • 422 Unprocessable entity
    • 423 Locked
    • 424 Method failure
    • 425 Too Early
    • 426 Upgrade Required
    • 428 Precondition Required
    • 429 Too Many Requests
    • 431 Request Header Fields Too Large
    • 451 Unavailable For Legal Reasons
  • 5xx codes (Server errors)
    • 500 Internal Server Error
    • 501 Not Implemented
    • 502 Bad Gateway or Proxy Error
    • 503 Service Unavailable
    • 504 Gateway Time-out
    • 505 HTTP Version not supported
    • 506 Variant Also Negotiates
    • 507 Insufficient storage
    • 508 Loop detected
    • 510 Not extended
    • 511 Network authentication required
Component: wd300awws.dll
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/12/2024

Send a report | Local help