簡體   English   中英

如何解決“請求 URI 中指定的查詢參數之一的值無效”錯誤?

[英]How to resolve `Value for one of the query parameters specified in the request URI is invalid` error?

我正在嘗試在 ALDS gen2 容器中創建鑲木地板文件,但失敗並出現以下錯誤

Status code 400, "{"error":{"code":"InvalidQueryParameterValue","message":"Value for one of the query parameters specified in the request URI is invalid.\nRequestId:0dec0224-c01f-0048-5227-36ecfc000000\nTime:2023-02-01T10:23:08.8603292Z"}}"

下面是我用來創建文件的代碼片段:

public void uploadFile(File fileToUpload) {
    StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential("adlssynapse123","accountKey");

    DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
    DataLakeServiceClient dataLakeServiceClient =
            builder.credential(sharedKeyCredential).endpoint(endpoint).buildClient(); 

    DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.getFileSystemClient("hdfs");

    DataLakeDirectoryClient directoryClient =fileSystemClient.getDirectoryClient("synapse/workspaces/adls-synapse/warehouse/adlstesting");

    DataLakeFileClient fileClient = directoryClient.createFile(fileToUpload.getName()); // This is where the execution fails

    fileClient.uploadFromFile(fileToUpload.getPath());
}

有人可以幫助解決這個問題嗎?

狀態代碼 400,“{“錯誤”:{“代碼”:“InvalidQueryParameterValue”,“消息”:“請求 URI 中指定的查詢參數之一的值無效。\nRequestId:0dec0224-c01f-0048-5227 36ecfc000000 \n時間:2023-02-01T10:23:08.8603292Z"}}"

上述錯誤表明請求 URI 上指定的查詢參數之一無效。

問題可能與提供給“createFile”方法的"fileToUpload.getName() ”參數有關,因為這是執行失敗的地方。 驗證 fileToUpload.getName() 的值是否為有效文件名並確定 API 的要求。

要在 ADLS Gen 2 中創建鑲木地板文件並上傳,您可以參考以下示例代碼:

代碼:

 public static void main( String[] args )
    {
     StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential("Straccountname","<Account key>");
     DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
     DataLakeServiceClient dataLakeServiceClient =builder
     .credential(sharedKeyCredential)
     .endpoint("https://Straccountname.dfs.core.windows.net")
     .buildClient(); 
     DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.getFileSystemClient("test");
     DataLakeDirectoryClient directoryClient =fileSystemClient.getDirectoryClient("synapse/workspaces");
     DataLakeFileClient fileClient = directoryClient.getFileClient("demo.parquet");
     fileClient.uploadFromFile("<filepath>");
  
    }

安慰:

在此處輸入圖像描述

門戶網站:

在此處輸入圖像描述

參考:

使用 Java 管理 Azure Data Lake Storage Gen2 中的數據 - Azure Storage | 微軟學習

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM