Problem
A REST client with Authentication: BASIC (Username: 'user', Password: '...!...') serializes successfully and passes mx check, but at runtime the outgoing HTTP request contains no Authorization header — the server returns 401. The same credentials work when passed to an inline REST CALL ... AUTH BASIC ... action.
Reproduction
CREATE REST CLIENT Module.API (
BaseUrl: 'https://api.example.com',
Authentication: BASIC (Username: 'user', Password: 'TMT5wgw-zut!cbp-rqp')
)
{
OPERATION GetData { Method: GET, Path: '/data', Response: NONE }
};
CREATE MICROFLOW Module.Test ()
BEGIN
SEND REST REQUEST Module.API.GetData;
END;
/
Runtime: 401 Unauthorized, no Authorization: Basic ... header in the outgoing request.
Compare with inline:
REST CALL GET 'https://api.example.com/data'
AUTH BASIC 'user' PASSWORD 'TMT5wgw-zut!cbp-rqp'
RETURNS String;
Works correctly — sends the auth header.
Investigation (BSON is correct)
Inspected the BSON produced by mxcli for the REST client:
"AuthenticationScheme": {
"$Type": "Rest$BasicAuthenticationScheme",
"Username": { "$Type": "Rest$StringValue", "Value": "user" },
"Password": { "$Type": "Rest$StringValue", "Value": "TMT5wgw-zut!cbp-rqp" }
}
The ! character is stored verbatim (not escaped, not interpreted as a template placeholder). The BSON structure matches what Studio Pro produces for the same credentials.
This points to a Mendix runtime issue: the REST client call action (Microflows$RestOperationCallAction) is not picking up the REST client's AuthenticationScheme correctly at request time, or something about the password string is tripping a template-engine pass before the value is applied.
Suggested fix
- Verify on the Mendix side: is there a known issue with
Rest$StringValue containing ! or other characters that the ValueTemplate engine treats as special? If so, the value should be stored as a literal (e.g., a Rest$ConstantValue or with explicit escaping).
- Workaround (already works): store the password as a
$Constant reference — Password: $ApiPassword — which is stored as Rest$ConstantValue and bypasses any template processing.
Related
Problem
A REST client with
Authentication: BASIC (Username: 'user', Password: '...!...')serializes successfully and passesmx check, but at runtime the outgoing HTTP request contains no Authorization header — the server returns 401. The same credentials work when passed to an inlineREST CALL ... AUTH BASIC ...action.Reproduction
Runtime: 401 Unauthorized, no
Authorization: Basic ...header in the outgoing request.Compare with inline:
Works correctly — sends the auth header.
Investigation (BSON is correct)
Inspected the BSON produced by mxcli for the REST client:
The
!character is stored verbatim (not escaped, not interpreted as a template placeholder). The BSON structure matches what Studio Pro produces for the same credentials.This points to a Mendix runtime issue: the REST client call action (
Microflows$RestOperationCallAction) is not picking up the REST client'sAuthenticationSchemecorrectly at request time, or something about the password string is tripping a template-engine pass before the value is applied.Suggested fix
Rest$StringValuecontaining!or other characters that the ValueTemplate engine treats as special? If so, the value should be stored as a literal (e.g., aRest$ConstantValueor with explicit escaping).$Constantreference —Password: $ApiPassword— which is stored asRest$ConstantValueand bypasses any template processing.Related