I’m having trouble with Azure OpenAI when trying to send messages with PDF attachments
I upload a document file successfully, create a new thread, then attempt to post a message that includes both text content and the uploaded file. The API keeps returning this error:
{
"error": {
"message": "Missing required parameter: 'content'.",
"type": "invalid_request_error",
"param": "content",
"code": "missing_required_parameter"
}
}
Here’s my request payload structure:
var requestPayload = new
{
role = "user",
content = "Please analyze this document and provide a summary.",
attachments = new[]
{
new
{
file_id = uploadedFileId,
tools = new[] { new { type = "file_search" } }
}
}
};
var jsonPayload = JsonSerializer.Serialize(requestPayload, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
var httpContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
var apiResponse = await httpClient.PostAsync(
$"{azureEndpoint}/openai/threads/{threadId}/messages?api-version=2024-08-01-preview",
httpContent
);
var responseText = await apiResponse.Content.ReadAsStringAsync();
if (!apiResponse.IsSuccessStatusCode)
{
Console.WriteLine($"Request failed: {apiResponse.StatusCode} - {responseText}");
}
The content field is clearly included in my request, so why does Azure OpenAI still complain about it being missing?