Skip to content

Debugging Call External API and Functions

This page helps you find out why a Call External API step failed, or why your own endpoint (an Azure Function or AWS Lambda) ran but the work item did not change. Each section starts from what you see. For the step's settings, see Call External API. For the endpoint pattern, see Your Own Endpoint.

Where to look first

  1. Open the work item in Monitor or Insight and read, at work-item level:
  2. ApiResults.LastHttpStatusCode: the status of the last response. It is not updated when no response arrived.
  3. ApiResults.<Response Metadata Key>: the response body, if the step has a key. Set one while you debug: error bodies usually say exactly what is wrong.
  4. Error.LastErrorMessage and Error.LastErrorStepName: the step error.
  5. Check your endpoint's own log (Application Insights, CloudWatch) for the same time.

Summary

Symptom Group
API domain not valid Step error messages
REST verb not supported Step error messages
Misused header name Step error messages
Invalid URI Step error messages
400 Bad Request Step error messages
401 Unauthorized Step error messages
Other status codes Step error messages
The step failed, and the routes never ran Step fails or times out
The step timed out Step fails or times out
Status 200, but nothing changed Wrong result on the work item
Values were written to the wrong work item Wrong result on the work item
Values doubled or appended twice Wrong result on the work item
The route still takes the default Wrong result on the work item
Azure Function cannot load System.Linq Function host and local runs
The token is null in the debugger Function host and local runs

Step error messages

API domain not valid

  • Message Api domain is not valid.
  • Cause The host resolves to a local or private address (localhost, 127.x, 10.x, 172.16.x to 172.31.x, 192.168.x), or does not resolve at all. The step refuses it before any request and writes nothing to ApiResults.
  • Fix Use a public host name. Deploy the function before you test from a workflow.
  • Debug locally Send the request to your machine yourself; see Your Own Endpoint.

REST verb not supported

  • Message Rest verb ... is not supported. Allowed: [GET, POST]
  • Cause The step uses DELETE, PUT or PATCH. The list offers them, but the step runs only GET and POST.
  • Fix Use GET or POST. If your API needs another verb, put a small endpoint in front of it.

Misused header name

  • Message Misused header name
  • Cause HTTP Headers contains Content-Type.
  • Fix Remove it. The Body Type sets Content-Type.

Invalid URI

  • Message Invalid URI
  • Cause The URL is empty or malformed, often a Liquid preprocessor that rendered nothing because a key was missing.
  • Fix Check the URL template and the metadata it reads. Liquid renders a missing key as empty text, with no error.

400 Bad Request

  • Message HTTP Response status code does not indicate success: 400 (Bad Request).
  • Cause The body does not match the receiver's contract: property casing, "True" instead of true, a date that is not ISO 8601, a missing field, or invalid JSON from a Liquid template.
  • Fix Read the stored response body. Build JSON bodies with a Javascript preprocessor and JSON.stringify.
  • See Post Form Data to Your API and Handle Failures

401 Unauthorized

  • Message HTTP Response status code does not indicate success: 401 (Unauthorized).
  • Cause Missing or wrong credentials: the function key (?code=), an API key header, or a token that was rotated or deleted.
  • KnowledgeLake API When the receiver is the KnowledgeLake API itself, it answers User Is Unauthorized on endpoint ..., and the cause can also be a token without the needed feature.
  • Fix Check the credential where the step gets it: the URL, HTTP Headers, or the secret global variable behind them.
  • See Rotate an API Token Without Breaking Workflows

Other status codes

Status Likely cause
403 A gateway, firewall or WAF in front of the endpoint blocks the request, or the key lacks the scope. The request comes from the KnowledgeLake cloud, not your network.
404 Wrong path, for example a function name with a different case, or a missing /api/ segment on Azure.
405 The endpoint does not accept the verb. Check the trigger's allowed methods.
412 From the KnowledgeLake API (when the step or your function calls it): an application error, with the details in Messages. For example No hold was found for workitem {id} from V1_WorkflowAPI/ReleaseHold on a work item that is not on hold.
413 The body is over the receiver's size limit. Send ids, not content.
422 From the KnowledgeLake API: the request body does not match the action's schema.
5xx The endpoint threw. Read its log.

Step fails or times out

The step failed, and the routes never ran

  • Cause A non-2xx response fails the step. With the default Error Behavior Stop, the work item goes into an error state before the routes run.
  • Fix Set Error Behavior to Continue and route on ApiResults.LastHttpStatusCode.
  • See Routes

The step timed out

  • Cause The step's Timeout passed (15 minutes when set to 0). The step fails without writing ApiResults.
  • Fix Keep the step timeout below your platform's limit. An HTTP-triggered Azure Function must answer within 230 seconds. An API Gateway in front of a Lambda ends requests after 29 seconds by default.
  • Check Whether the endpoint finished anyway. If its log shows success after the step gave up, the work item has the endpoint's writes, but the step still failed. Make the endpoint faster or answer sooner.

Wrong result on the work item

Status 200, but nothing changed

  • Symptom Status 200, but nothing changed on the work item.
  • Cause The function caught an exception and returned 200 anyway, or it checked no Success flag and an API call failed with HTTP 200 and Success: false.
  • Fix Return non-2xx on every failure. Check Success on every API response and fail when it is false.
  • Permissions If the log shows a missing permission, recreate the token with Manage Work Items.

Values were written to the wrong work item

  • Cause The function read the work item id from the body or from a hardcoded test value.
  • Fix Read the WorkItemId header. Keep test ids under #if DEBUG, used only when the header is missing.

Values doubled or appended twice

  • Cause The step was retried, or ran again after a timeout, and the function appended or incremented.
  • Fix Upsert final values. Never append or increment.

The route still takes the default

  • Symptom The route still takes the default after the function wrote values.
  • Cause The function wrote document metadata, but routes read work-item metadata. Or the keys differ in case (needsReview is not NeedsReview).
  • Fix Also write a work-item value with UpsertWorkItemMetadata. Use the exact key names.

Function host and local runs

Azure Function cannot load System.Linq

  • Message Could not load file or assembly 'System.Linq, Version=8.0.0.0'
  • Cause An in-process .NET 8 Azure Function without FUNCTIONS_INPROC_NET8_ENABLED = 1.
  • Fix Add the app setting, and the same value in local.settings.json.

The token is null in the debugger

  • Cause The process started before you set the user environment variable KnowledgeLakeApiToken.
  • Fix Restart Visual Studio or the terminal.

A repeatable test

  1. Run a test work item into a workflow that stops at a hold step, so it stays open.
  2. Call your endpoint yourself, with the same URL, headers and body as the step, and the WorkItemId header. Compare the response with what the step stored.
  3. Fix, then restart the step on the work item from Monitor or Insight.