Share via

Microsoft Foundry HTTP 500 error

Bernardo Wiemer | Hiram 0 Reputation points
2026-02-27T15:46:12.3166667+00:00

Hi,

I have been building a workflow using the new Microsoft Foundry, and once I've tested it in the Portal UI, using the Preview feature, I have published my workflow, giving me a endpoint following:
https://<resource-name>.services.ai.azure.com/api/projects/<project-name>/applications/<workflow-name>/protocols/activityprotocol?api-version=2025-11-15-preview

This is currently getting called via a fetch request in my localhost environment. To authenticate, I'm using this helper function:

const { DefaultAzureCredential } = require("@azure/identity");
const cred = new DefaultAzureCredential();
async function getAiAzureBearer() {
  const t = await cred.getToken("https://ai.azure.com/.default");
  if (!t?.token) throw new Error("Falha ao obter token (ai.azure.com)");
  return t.token;
}

And the request is being sent via:

async function runFoundryWorkflow({ invokeUrl, input }) {
    const token = await getAiAzureBearer();
    const bodyObj = { input };

    const bodyStr = JSON.stringify(bodyObj);

    const res = await fetch(invokeUrl, {
        method: "POST",
        headers: {
            Authorization: `Bearer ${token}`,
            "Content-Type": "application/json",
            "Accept": "application/json"
        },
        body: bodyStr,
    });

    const text = await res.text();

    if (!res.ok) {
        let reqId = null;
        try { reqId = JSON.parse(text)?.error?.additionalInfo?.request_id; } catch (_) { }
        console.error("[FOUNDRY WF ERROR]", {
            status: res.status,
            request_id: reqId,
            payload_bytes: Buffer.byteLength(bodyStr, "utf8"),
            payload_head: bodyStr.slice(0, 2000),
            response_head: text.slice(0, 2000),
            headers: Object.fromEntries(res.headers.entries()),
        });
        throw new Error(`Workflow HTTP ${res.status}: ${text}`);
    }

    try { return JSON.parse(text); } catch { return text; }
}

But I always receive the same response, HTTP 500 error:

"error": {
    "code": "server_error",
    "message": "An error occurred while processing your request. You can retry your request, or contact us if the error persists. Please include the request ID <requestId> in your message.",      
    "type": "error",
    "details": [],
    "additionalInfo": {
      "request_id": "<requestId>"
    }
  }

I'm not sure whether my Workflow YAML is assigning the body of the request to the correct variable, it should assign the "input" in the body to the Local.input variable. But since I'm triggering it via the HTTP request (and not OnConversationStart), it probably isn't, and that is the only reason I can think that could be causing the 500 error. Here is the YAML of my workflow:

kind: workflow
trigger:
  kind: OnConversationStart
  id: trigger_wf
  actions:
    - kind: SetMultipleVariables
      id: node-1771965874882
      assignments:
        - variable: Local.final_result
          value: =
        - variable: Local.input
          value: =
        - variable: Local.classified
          value: =
        - variable: Local.classification_obj
          value: =
        - variable: Local.final_result_obj
          value: =
    - kind: InvokeAzureAgent
      id: node-1771965870373
      agent:
        name: doc-classifier
      conversationId: =System.ConversationId
      input:
        messages: =Local.input
      output:
        autoSend: true
        responseObject: Local.classification_obj
    - kind: InvokeAzureAgent
      id: node-1771965871830
      agent:
        name: doc-extractor
      conversationId: =System.ConversationId
      input:
        messages: =Local.classification_obj
      output:
        autoSend: true
        responseObject: Local.final_result_obj
    - kind: EndConversation
      id: node-1771966048400
id: ""
name: document-classifier-and-extractor
description: ""

I have tried changing the signature to CognitiveServices, but returns that it was impossible to validate JWT token (and doesn't really make any sense).

I have also tried different kinds of payload, like wrapping it in { } and with different names. Also tried setting the value of Local.input to System.LastMessage.Text and System.LastMessageText (don't know the difference), but to no avail.

I've been trying this for 3 days now and just can't find the right documentation on how to call the endpoint of the published (new) Microsoft Foundry Workflow.

Thanks in advance.

Azure OpenAI Service
Azure OpenAI Service

An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.

{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 41,566 Reputation points MVP Volunteer Moderator
    2026-03-01T01:05:12.5966667+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    I think you are not starting a conversation. You are sending an activity payload.

    So:

    Local.input never receives anything • System.LastMessage is empty • the agent receives messages = null • the agent runtime throws internally • platform returns HTTP 500

    This is why you are seeing a generic server error instead of validation errors.

    The activity endpoint expects a Bot Framework–style activity, not a custom JSON body.

    Your payload must look like this:

    {
      "type": "message",
      "from": { "id": "user" },
      "text": "your input text here"
    }
    
    

    Not:

    That format is only valid for portal preview.

    { "input": "..." }
    
    

    option 1 : easiest -> keep workflow, change request body

    Change your fetch body to:

    const bodyObj = {
      type: "message",
      from: { id: "user" },
      text: input
    };
    
    

    Then inside YAML use:

    messages: =System.Activity.Text
    

    Do not use Local.input.

    This works because activity protocol injects input into System.Activity.

    option 2 : architecturally correct: add HTTP trigger

    Instead of conversation start:

    trigger:
      kind: OnHttpRequest
    
    

    Then map body explicity as below:

    assignments:
      - variable: Local.input
        value: =System.HttpRequest.Body.input
    
    

    Now your existing JavaScript payload will work unchanged.

    This is the proper design if you are building API-style workflows rather than chat agents.

    Overall Check the below:

    1. confirm workflow trigger type
    2. match request format to trigger type
    3. use System.Activity.Text for activity protocol
    4. use System.HttpRequest.Body only for HTTP trigger
    5. do not mix portal-preview payload patterns with runtime API patterns

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.