Skip to content

REST client BASIC auth: password with special characters produces 401 at runtime #200

@ako

Description

@ako

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

  1. 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).
  2. Workaround (already works): store the password as a $Constant reference — Password: $ApiPassword — which is stored as Rest$ConstantValue and bypasses any template processing.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions