Base-64 Decoding Error When Calling External API via Flow Designer REST Step
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
My @Servicenow Version - Zurich
I'm encountering a Base-64 decoding error when making a REST API call from Flow Designer to an external API. The error message states:
"The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."
Setup:
Flow Designer Configuration:
- Script Step: Collects RITM variables and builds JSON payload
- REST Step: Calls external API using Connection & Credential Alias
REST Step Configuration:
- Headers:
- Accept: application/json
- Content-Type: application/json
- Connection: Using Connection & Credential Alias
- Request Type: POST
Sample Payload (JSON):
json{ "Employee ID": "SampleUser", "Employee Name": "Sample User", "Employee Email Address": "sample-user@lxxxxxx.com", "Request Type": "device order", "Order Type": "New", "Catalog ID": "11A58F63", "Shipping Address ATTN": "Sample User", "Shipping Address 2": "", "Shipping Address City": "Austin", "Shipping Address Postal Code": "73301", "Shipping Address 1": "123 Mockingbird Ln", "Shipping Country": "US", "Shipping Address State": "TX", "Home ZIP Code": "73301", "Business Justification - Optional": "Required to enable full mobile productivity via the ServiceNow Mobile/Agent apps, ensure secure network access via Multi-Factor Authentication (MFA), and provide essential backup cellular connectivity to ensure business continuity during travel or home ISP outages" }API Response Headers:
Server: Microsoft-IIS/10.0 Content-Type: application/json; charset=utf-8 X-Powered-By: ASP.NET Set-Cookie: ARRAffinity=... (Azure App Service)Questions:
- Does the API expect the JSON payload to be Base-64 encoded before sending?
- Should I encode the entire JSON string in my Script Step?
- Should I change my Script Step output variable type from string to string (full UTF-8)?
- The payload contains special characters: hyphens, slashes, parentheses
- Could this be an authentication issue?
- Is the error coming from a malformed credential being Base-64 decoded by the API?
- Authentication type: [Basic Auth / OAuth / API Key]
- Is the error occurring on the ServiceNow side (request) or the API side (response)?
- From Flow Execution Details, the error appears in the [Request/Response]
Script Step Code:
javascript(function execute(inputs, outputs) { var payload = { "Employee ID": inputs.employee_id, "Employee Name": inputs.employee_name, "Employee Email Address": inputs.email, "Request Type": inputs.request_type, "Order Type": inputs.order_type, "Catalog ID": inputs.catalog_id, "Shipping Address ATTN": inputs.shipping_attn, "Shipping Address City": inputs.shipping_city, "Shipping Address Postal Code": inputs.shipping_postal, "Shipping Address 1": inputs.shipping_addr1, "Shipping Country": inputs.shipping_country, "Shipping Address State": inputs.shipping_state, "Home ZIP Code": inputs.home_zip, "Business Justification - Optional": inputs.business_justification }; outputs.json_payload = JSON.stringify(payload); })(inputs, outputs);Additional Context:
- The external API is hosted on Azure App Service (IIS 10.0)
- No API documentation available regarding Base-64 encoding requirements
- This is for an automated device ordering integration from ServiceNow RITM to external vendor system
Seeking Advice On:
- Should I Base-64 encode the JSON payload before sending?
- How to properly handle UTF-8 characters in Flow Designer REST integrations?
- Best practices for debugging Base-64 errors in outbound REST calls?
- Could this be related to Connection & Credential Alias configuration?
Any guidance would be greatly appreciated!
Tags: #FlowDesigner #RESTapi #IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
better to check with the 3rd party API team without which you will be stuck in exploring what they want in API request.
Ask them to share sample JSON request body etc and API response you will get.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
47m ago
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
