REST Client Header Support
The following JadeRestRequest class constants and methods enable you to add, modify, remove, and view the headers that are to be sent in a REST request.
-
JadeRestRequest class AddHeader_Forbidden and AddHeader_Success constants.
-
JadeRestRequest methods:
-
addHeader, which adds or modifies the header specified in the key parameter with the value specified in the value parameter
-
getAllHeaders, which returns all headers that will be included in the REST request that can be modified
-
getHeaderValue, which returns the value of the header specified in the key parameter if it has been set
-
isHeaderForbidden, which returns true if the header specified in the header parameter is one that is forbidden and cannot be modified
-
setAcceptHeader, which sets the Accept header to the value specified in the value parameter
-
setContentTypeHeader, which sets the Content‑Type header to the value specified in the value parameter
-
setPragmaHeader, which sets the Pragma header to the value specified in the value parameter
-
setUserAgentHeader, which sets the User-Agent header to the value specified in the value parameter
-
The special forbidden headers that cannot be modified are listed at:
https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
The following method is an example of adding a header that is to be sent in a REST request.
sendBasicAuthExample(); vars client : JadeRestClient; request : JadeRestRequest; response : JadeRestResponse; base64EncodedCreds : String; begin client := create JadeRestClient("http://localhost/JadeRestSite/jadehttp.dll"); request := create JadeRestRequest('headers'); base64EncodedCreds := "ThisIsNotARealUsername:ThisIsNotARealPassword".Binary.base64Encode(); request.addHeader("Authorization", "Basic " & base64EncodedCreds); write request.getAllHeaders(); /* Authorization: Basic VABoAGkAcwBJAHMATgBvAHQAQQBSAGUAYQBsAFUAcwBlAHIAbgBhAG0AZQA6AFQAa ABpAHMASQBzAE4AbwB0AEEAUgBlAGEAbABQAGEAcwBzAHcAbwByAGQA */ create response; client.get(request, response); epilog delete client; delete request; delete response; end;
2022.0.01 and higher