Closed Ksdmg closed 5 months ago
Thank you for reporting this. I'm pretty sure that's a bug in our URITemplate generation here https://github.com/microsoft/kiota/blob/b2fa1faad08e61a6dad249a443e9b955ec3dc93a/src/Kiota.Builder/Extensions/OpenApiUrlTreeNodeExtensions.cs#L199 . If you state that the parameters are required the key should always appear in the URL.
The URL Template for a required parameter should be created like this:
https://example.org?key={key}{&otherparam1, otherParam2}
It think we are currently generating it like this,
https://example.org{?key,otherparam1, otherParam2}
I ran into something similar with work I was doing.
Hi @ksdmg,
Thanks for using kiota and for reaching out.
Can you open the GetRowsRequestBuilder
class please and provide us with the URI Template please? (it should start with {+baseurl}/
), I'd like to confirm whether this is a generation issue or a runtime behavior in the abstractions code.
Thanks!
@baywet , here is the uri template:
"{+baseurl}/{currentCompany}/Erp.BO.EmpBasicSvc/GetRows{?whereClauseEmpBasic*,whereClauseEmpBasicAttch*,whereClauseEmpLabExpRate*,whereClauseEmpCal*,whereClausePartner*,whereClauseResourceCal*,whereClauseEmpRole*,whereClauseEntityGLC*,whereClauseEmpRoleRt*,pageSize*,absolutePage*}"
@ksdmg Thanks. I think there was a mismatch here. None of the query parameters match what's in the description you've provided (besides the paging ones) and the Erp.BO.EmpBasicSvc
doesn't match the Erp.BO.LaborSvc
path segment from the description. Can you double check you've provided the URI template from the matching request builder please?
@baywet sorry I got confused because the methods had the same name. Here is the Erp.BO.LaborSvc.GetRows
:
{+baseurl}/{currentCompany}/Erp.BO.LaborSvc/GetRows{?whereClauseLaborHed*,whereClauseLaborDtl*,whereClauseLaborDtlAttch*,whereClauseLaborDtlComment*,whereClauseLaborEquip*,whereClauseLaborPart*,whereClauseLbrScrapSerialNumbers*,whereClauseLaborDtlGroup*,whereClauseSelectedSerialNumbers*,whereClauseSNFormat*,whereClauseTimeWeeklyView*,whereClauseTimeWorkHours*,pageSize*,absolutePage*}
Thanks for confirming, this is most likely caused because of this line at runtime
Transferring the issue.
@ksdmg do you think you'd be able to implement a unit test for your use case like this one and validate that it fails with the current code, but it passes when the line I outlined is removed?
@baywet, no I do not have enough knowledge about Kiota to create a meaningful Unit test for this.
Thanks for letting us know. @andrueastman can you take this over when you have some time please?
When trying to use this endpoint without all parameters being set, I would expect Kiota to send empty parameters as they have the property "allowEmptyValue" but also are "required".
What Kiota actually does, is it omits these parameters resulting in an error.
As an example, this is the url that swagger generates when I select to sent empty values for all parameters where allowed:
Versus Kiota where all parameters that have not been set are omitted:
I have tried to set the parameters to
string.Empty
and tonull
but both result in the parameters being omitted. The only workaround I found was setting the parameters to a whitespace which will be set by Kiota.