Why does the Username retrieved from the Get Credential activity contain extra characters like '​' or fail authentication even though it looks correct?
Symptom:
When using the Get Credential activity to retrieve a Credential Asset from Orchestrator, the retrieved Username variable contains extra, unexpected characters.
- Expected Value: prd.4
- Actual Value: prd.4​ (or prd.4 followed by an invisible character)
Impact:
- Authentication failures when using the retrieved username to log into external systems (e.g., SAP, Salesforce, Legacy Apps).
- String comparison operations fail (prd.4 ≠ prd.4​).
- Logs appear visually correct, but the automation fails due to the hidden payload.
Resolution & Troubleshooting Approaches
Follow the steps below in order (workaround first, then permanent fix).
A. Immediate Workaround (Code-Level)
If you cannot edit the asset immediately, clean the username variable using a Regex Assign activity.
- After Get Credential, add an Assign activity.
- Use the following expression to remove zero-width characters:
cleaned_username = System.Text.RegularExpressions.Regex.Replace(out_username, "[\s\u200B-\u200D\uFEFF]", "")
Where out_username is the output variable from the Get Credential activity.
Why out_username.Trim() approach fails in the RPA automation:
Trim() only removes spaces, tabs, and new lines (\s). It does not remove Zero-Width Spaces (\u200b).
B. Permanent Fix (Clean the Credential Asset in Orchestrator)
This resolves the issue at the source so no code cleaning is required.
- Navigate to Orchestrator → Folder containing the credential asset.
- Go to Assets → Locate the impacted Credential Asset.
- Click Edit.
- Delete the current username entirely.
- Type the username manually (e.g., prd.4). Do NOT copy/paste.
- Enter a completely different password (e.g., change Password1 to TempPass123). This forces a hard update in the backend database.
- Click Update.
- Edit the asset again and revert the password to the original correct value. Leave the username untouched.
- Click Update.
C. Verification
- In Orchestrator (API/Inspect -> Network): Re-run the GET API call. Confirm \u200b is no longer present.
2. In Studio: Run a test sequence with Get Credential and a Message Box/Log message activity displaying the username length.
- Expected length for "prd.4": 5
- If length is 6: Hidden character still exists.
Best Practice Recommendation
| Do | Don't |
| Manually type usernames directly into the Orchestrator UI form. | Copy/paste usernames from browsers, Word, Teams, or Outlook. |
| Use the Regex cleaning method above if assets are created via API. | Rely on .Trim() to clean invisible characters. |
Inspect raw API responses (/odata/Assets) when usernames behave unexpectedly. | Assume the UiPath Robot is corrupting the decryption. |
Root Cause
The username stored in the Orchestrator Credential Asset contains a Zero-Width Space (ZWSP) character at the end of the string.
Technical Details:
- Unicode Character: U+200B (Zero Width Space).
- Visual Representation: The sequence ​ appears when the ZWSP is interpreted via UTF-8/ANSI encoding mismatch (Mojibake).
- Source: Orchestrator does not allow trailing spaces via the UI, but it does preserve hidden Unicode characters injected via REST API calls or copy/paste from rich-text sources (Web pages, Teams, Outlook, Password Managers).
Evidence via Orchestrator RestAPI
Using the Orchestrator API endpoint below, the JSON response shows the raw stored value:
GET https://cloud.uipath.com/ORG_ID/TENANT_ID/orchestrator_/odata/Assets(ASSET_ID)?$expand=UserValues
{
...
"CredentialUsername": "prd.4\u200b"
...
}
The \u200b confirms the Zero-Width Space.
Note: This is not a decryption bug or a UiPath Robot defect. The activity is correctly returning exactly what is stored in the database.

