SetHttpRequestHeader
PowerScript function
Description
Sets the HTTP request header. This function is only used for
PowerServer and the request header that is set using this function is used
only when PowerServer API calls are being made.
Applies to
Syntax
|
1 |
applicationname.SetHttpRequestHeader ( string headerName, string headerValue{, Boolean replace } ) |
|
Argument |
Description |
|---|---|
|
applicationname |
The name of the application object in which you want to |
|
headerName |
A string whose value is the header name. |
|
headerValue |
A string whose value is the header value. |
|
replace (optional) |
A boolean determines whether to replace the current
Note: use this argument cautiously 1) TRUE is recommended |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs or if the current
application is not an installable cloud app deployed with PowerServer. If
any argument’s value is null, the method returns null.
Examples
The following code example sets the access token in the HTTP request
header:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Long ll_Return String ls_TokenType, ls_AccessToken, ls_Json JsonParser ljson_Parser ljson_Parser = Create JsonParser ls_Json = '{' +& ' "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjM4OEQ0NEIxRDdBNkVFOUQxNTU0MDAzQUMzM0QzQzkzIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2MTI0MDIxODUsImV4cCI6MTYxMjQwMjM2NSwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMSIsImNsaWVudF9pZCI6IllvdXJDbGllbnRJZFRoYXRDYW5Pbmx5UmVhZCIsInN1YiI6IlBBTkdDSFVHVUFOIiwiYXV0aF90aW1lIjoxNjEyNDAyMTg1LCJpZHAiOiJsb2NhbCIsImp0aSI6IjFDNEQ4NEFBODU0REYxODMwQkVGQTAwQTFBMjdFMDk0IiwiaWF0IjoxNjEyNDAyMTg1LCJzY29wZSI6WyJzY29wZS5yZWFkYWNjZXNzIl0sImFtciI6WyJjdXN0b20iXX0.DbJsip696O1HlTFjAmayohhHGEcjIQxJM7JICi9ho5MAv2Av4YjQOGgXrCNFhwqG4AFTf3hHwufGYXxzXI8tCYfn3F3ro36dd-0h_A-__5sBelZD0vr6nmWh8Uy-zoJenzsrnVEv8VHVNi2enuKH6SBe-Q59bn5A-Gbg6viNjv0S5HIaKuWeawExBH6uEAu28RlSlfG2bwWuCsyhYWOPIhNhYcZTbVD8ks0SFodGeGS-ZqNOVrOTKb9oqnhvYxnuNofJpjToZ8ZZdKyWiyJUhItpTQTyI3MsCHoVU4X101YTPrVMF_-OuPSwXm6QMl3QtI_6Hy_PeYHL-xz2-q3tog",' +& ' "expires_in": 3600,' +& ' "token_type": "Bearer",' +& ' "scope": "scope.readaccess"' +& '}' ljson_Parser.LoadString( ls_Json ) ls_TokenType = ljson_Parser.GetItemString( "/token_type" ) ls_AccessToken = ljson_Parser.GetItemString( "/access_token" ) ll_Return = Getapplication().SetHttpRequestHeader( "Authorization", ls_TokenType + " " + ls_AccessToken, True ) If IsValid ( ljson_Parser ) Then Destroy ( ljson_Parser ) |
The following code example sets the cookie in the HTTP request
header:
Notice that you can only set the cookie name and cookie value in the
key-value pairs (for example, “key1=value1; key2=value2”), and cannot set
the other properties such as Domain, Expires etc.
|
1 |
GetApplication().SetHttpRequestHeader ("cookie", "appcookie=test_cookie;PSTM=1634527936;") |
See also