Share via

In Microsoft foundry I unable to connect my agent through POST request

Auto Admin 0 Reputation points
2026-05-05T01:50:02.93+00:00

I use the endpoint provided by the Microsoft foundry of my agent and try to post request with the access token, the respond body look like

https://resource.services.ai.azure.com/api/projects/auto/agents/hr-agent/protocols/openai/v1/responses

{
    "error": {
        "code": "BadRequest",
        "message": "Missing required query parameter: api-version"
    }
}
Foundry Agent Service
Foundry Agent Service

A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model

0 comments No comments

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2026-05-05T01:50:11.82+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Add the required api-version query parameter to the agent endpoint URL when sending the POST request.

    For the Responses protocol, the correct pattern is:

    https://{account}.services.ai.azure.com/api/projects/{project}/agents/{agent}/protocols/openai/v1/responses?api-version=v1
    

    Example curl call:

    curl -X POST "https://resource.services.ai.azure.com/api/projects/auto/agents/hr-agent/protocols/openai/v1/responses?api-version=v1" \
      -H "Authorization: Bearer {access_token}" \
      -H "Content-Type: application/json" \
      -d '{
        "input": "Hello! What can you do?",
        "store": true
      }'
    

    Ensure:

    • api-version is present in the query string (for example, api-version=v1).
    • The path includes /agents/{agent}/protocols/openai/v1/responses (not /endpoint/protocols/... unless explicitly required by the preview flavor being used).

    If using hosted agents in the refreshed public preview, also include the preview header and the endpoint segment as shown in the hosted-agent example:

    curl -X POST "$BASE_URL/agents/my-agent/endpoint/protocols/openai/responses?api-version=v1" \
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json" \
      -H "Foundry-Features: HostedAgents=V1Preview" \
      -d '{"input": "Hello!", "model": "gpt-4.1", "stream": false}'
    

    Using the correct URL pattern plus ?api-version=v1 resolves the Missing required query parameter: api-version error.


    References:

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.