ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Web service functions
  • Code details
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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
// Indique la création du client : 201 Created
WebserviceWriteHTTPCode(201, "https://serveur/Client/" + Client.id)
// Et retourne le détail du client
RETURN sClient

// Indique l'absence de réponse : 204 No Content
WebserviceWriteHTTPCode(204)
// Et ne retourne pas de réponse
RETURN ""

// Accepte un contenu JSON ou XML
SWITCH WebserviceReadMIMEType()
	CASE "application/json"
		// Traite le cas JSON
		...
	CASE "application/xml"
		// Traite le cas XML
		...
	OTHER CASE
		// Traite les autres cas (lance une erreur)
		// Indique que les données reçus sont dans un format non reconnu : 
		// 415 Unsupported Media Type
		WebserviceWriteHTTPCode(415, sErreur)
	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:
  • Code 201 (Created): optional information: Address of added information.
  • Code 301 (Moved Permanently): mandatory information: redirection address.
  • Code 302 (Found): mandatory information: Redirection address.
  • Codes 4xx and 5xx: mandatory information: error text returned to customer. 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/27/2025

Send a report | Local help