0
votes

I am getting while setting meta data in azure data lake file using azure fileclient, it's throwing the exception like "Specified value has invalid HTTP Header characters. Parameter name: name in azure data lake"

I am using the Dictionary to set metadata.

PathHttpHeaders path = new PathHttpHeaders();
path.ContentType = "application/octet-stream";
fileClient.SetHttpHeaders(path);
var metaDataProperties = await GetMetaDataProperties(entityData);
await fileClient.SetMetadataAsync(metaDataProperties);
1
Can you post the code?Peter Bons
var entityData = JObject.Parse(wrapper.Payload); var metaDataProperties = await GetMetaDataProperties(entityData); await fileClient.SetMetadataAsync(metaDataProperties);gourav bhattacharya
COuld you please tell me which service you use? Gen1 or Gen2?Jim Xu
Could you please provide a sample data?Jim Xu
GEN 2, now it's working, the same fileclient instance was not setting the metadata which I have used to store the file into datalake. To resolve the issue I have created a new fileclient instance and it worked for me.gourav bhattacharya

1 Answers

0
votes

The above issue has been resolved, the issue was coming due to the FileClient instance, I was using the same FileClient instance which I have used to store the file into the Azure data lake. For resolving the issue I have created a new FileClient Instance and that worked for me. Below is my code.

private async Task SetMetaDataProps(MessageWrapper wrapper, Uri uri, string filename)
        {
            
            try
            {
                var entityData = JObject.Parse(wrapper.Payload);
                entityData["FileName"] = filename;
                var storageCredentials = new StorageSharedKeyCredential("accountName", "accountKey");
                var fileclient = new DataLakeFileClient(uri, storageCredentials);
                var metaDataProps = await GetMetaDataProperties(entityData);
                var ss = fileclient.SetMetadataAsync(metaDataProps);
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }