-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending files to API #5638
Comments
Hi @connorjjarvis Which version of kiota was used to generate this client? If not 1.19.1, please upgrade kiota and update the generated client. More context #5545 |
After installing the version 1.19.1 (Tool 'microsoft.openapi.kiota' was reinstalled with the stable version (version '1.19.1').) Rerunning the Kiota generate command: dotnet kiota generate -l CSharp -c ApiClient -n Api -d https://localhost:5001/swagger/v1/swagger.json -o ./ -b No changes were made to the files and the problem is still happening for me, I'll retry it all again in the morning (UK Time) to see if I missed something |
Thank you for the additional information. Can you please share your OpenAPI description? or a minimal reproduction description if it's large? |
I've reduced it down quite a bit, here is the OpenAPI spec OpenAPI Spec
On this endpoint here: "/workItems/uploadCsv" when Kiota generates this, it wants us to send it as a UploadCsvPostRequestBody with the property "File" as a string. |
Thank you for the additional information. For others reading this, here is a smaller repro {
"openapi": "3.0.1",
"info": {
"title": "Howden Pipelines Web API 1.0",
"version": "1.0",
"description": "goo"
},
"servers": [
{
"url": "https://localhost:5001",
"description": "Localhost"
}
],
"paths": {
"/workItems/uploadCsv": {
"post": {
"tags": [
"WorkItem"
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"file": {
"style": "form"
}
}
},
"text/csv": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"file": {
"style": "form"
}
}
}
}
},
"responses": {
"201": {
"description": "Created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CsvUploadResult"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"CsvError": {
"type": "object",
"properties": {
"Row": {
"type": "integer",
"format": "int32"
},
"Column": {
"type": "string",
"nullable": true
},
"Error": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"CsvUploadResult": {
"type": "object",
"properties": {
"IsSuccess": {
"type": "boolean",
"readOnly": true
},
"Errors": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CsvError"
},
"nullable": true
},
"Count": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
}
}
}
} |
I was able to reproduce the issue and put together #5639 to address it. |
Issue
I'm encountering an issue when sending a file to the API using Kiota. The error message returned is:
Expected a MultiPartBody instance, but got UploadCsvPostRequestBody
The UploadCsvPostRequestBody class only has a string File property.
Has anyone managed to send a file via Kiota and can help me out here?
Code Snippet
API Endpoint
The text was updated successfully, but these errors were encountered: