-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Describe the bug
Im trying to upload a file from a code app, this feature its not supported using add-data-source -a dataverse -t ...
So, i added de shared common service connector to the app as it was a custom connector.
The sdk generated all the methods, i had noted that using non organization specific methods dosent work, so i try this one..
`
/**
- Upload a file or an image to selected environment
- Update file or image content in a row in a Power Platform environment.
*/
public static async UpdateEntityFileImageFieldContentWithOrganization(content_type: string, organization: string, entityName: string, recordId: string, fileImageFieldName: string, item: string, x_ms_file_name: string): Promise<IOperationResult> {
const params: { content_type: string, organization: string, entityName: string, recordId: string, fileImageFieldName: string, item: string, x_ms_file_name: string } = { content_type, organization, entityName, recordId, fileImageFieldName, item, x_ms_file_name };
const result = await MicrosoftDataverseService.client.executeAsync<{ content_type: string, organization: string, entityName: string, recordId: string, fileImageFieldName: string, item: string, x_ms_file_name: string }, void>(
{
connectorOperation: {
tableName: MicrosoftDataverseService.dataSourceName,
operationName: 'UpdateEntityFileImageFieldContentWithOrganization',
parameters: params
},
});
return result;
}
`
The problem is that the sdk, is sending a bad request to the invoke endpoint, so im getting a 400 error.
{
"error": {
"code": "0x80048d19",
"message": "Error identified in Payload provided by the user for Entity :'', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.OData.ODataException: A top-level property with name 'item' was found in the payload; however, property and collection payloads must always have a top-level property with name **'value'.\r\n
to debug this, i call the connector endpoint myself (without invoke) and the following request succeeded..
curl --location --request PUT 'https://bbeae572-ff04-e89b-89b1-d91671b42ae9.10.common.brazil.azure-apihub.net/apim/commondataserviceforapps/shared-commondataser-fakeid.../api/data/v9.1.0/tcs_documentos(9a7781a3-68cc-f011-8544-002248364293)/tcs_file?x-ms-file-name=postman.pdf' \ --header 'Authorization: Bearer eyJ0e....' \ --header 'content-type: application/octet-stream' \ --header 'Cookie: ... --data '{"item":"JVBERi0xLjQKJZOMi54gUmVwb3J0TGFiIEdlbmVyYXRlZCBQREYgZG9jdW1lbnQgaHR0cDovL3d3dy5yZXBvcnRsYWIuY29tCjEgMCBvYmoKPDwKL0YxIDIgMCBSCj4"}'
Also, i try debuggin with a simple update operation using this function:
public static async UpdateRecordWithOrganization(prefer: string, accept: string, organization: string, entityName: string, recordId: string, item: Record<string, unknown>, x_ms_odata_metadata_full?: boolean): Promise<IOperationResult<Record<string, unknown>>> { const params: { prefer: string, accept: string, organization: string, entityName: string, recordId: string, item: Record<string, unknown>, x_ms_odata_metadata_full?: boolean } = { prefer, accept, organization, entityName, recordId, item, x_ms_odata_metadata_full }; const result = await MicrosoftDataverseService.client.executeAsync<{ prefer: string, accept: string, organization: string, entityName: string, recordId: string, item: Record<string, unknown>, x_ms_odata_metadata_full?: boolean }, Record<string, unknown>>( { connectorOperation: { tableName: MicrosoftDataverseService.dataSourceName, operationName: 'UpdateRecordWithOrganization', parameters: params }, }); return result; }
this also fails, beacuse the property "item" is added to the payload.
curl ^"https://bbeae572-ff04-e89b-89b1-d91671b42ae9.10.common.brazil.azure-apihub.net/invoke^" ^
-H ^"accept: application/json, application/json^" ^
-H ^"accept-language: es-ES^" ^
-H ^"authorization: Bearer eyJ0..." ^
-H ^"x-ms-client-app-id: /providers/Microsoft.PowerApps/apps/local^" ^
-H ^"x-ms-request-method: PATCH^" ^
-H ^"x-ms-request-url: /apim/commondataserviceforapps/shared-commondataser-827cb6b7-680c-4d0f-aeaf-17690ee343eb/api/data/v9.1.0/tcs_documentos(9a7781a3-68cc-f011-8544-002248364293)^" ^
-H ^"x-ms-user-agent: PowerApps/3.25111.8 (Web Player; AppName=local)^" ^
--data-raw ^"^{^^"item^^":^{^^"tcs_nombre^^":^^"Chefs-y-Primeros-Chefs.pdf^^",^^"tcs_id^^":^^"35-1011.00^^"^}^}^"
"message": "Error identified in Payload provided by the user for Entity :'', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.Crm.CrmException: Invalid property 'item' was found in entity
Cloning that request into postman, and removing the "items" property, solves the issue.
Steps to Reproduce
- add dataverse (shared_common_service) connector and let the sdk generate the service.
- Call any of the above described methods.
- See the bad request error.
Expected behavior
The common data service connector should work as any other custom connector y code apps..
Actual behavior
it dosent work.