none
ADLS Gen 2 REST API's help RRS feed

  • Question

  • Hi all,



    I am trying to use the Path create adls gen2 rest api to rename a file and also a directory. I am being returned an error saying I am missing a required http header. Headers I have included are "x-ms-rename-source", "x-ms-date" and "x-ms-version". I am assuming this is an easy fix but I'm not sure from the documentation (https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/create) exactly what other header is required?

    Any help is greatly appreciated!


    Tuesday, March 19, 2019 2:15 PM

All replies

  • Hi Ewan,

    I think you are missing "Content-length" and "Authorization" headers.

    For example :

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata?resource=filesystem"

    Hope this helps.


    MSDN

    Wednesday, March 20, 2019 9:23 AM
    Moderator
  • Hi Chirag,

    I have the same issue and I wanted to try your example but it doesn't look like an example for renaming the file. Could you please provide an example for renaming the file in ADLS Gen 2?

    Friday, August 30, 2019 9:35 AM
  • Hi there,

    Sorry for the delay in the response. Here's an approach to rename a file (Ref : https://stackoverflow.com/a/55448076/10653466) :

    request headers :

      DateTime now = DateTime.UtcNow;
      requestMessage.Headers.Add("x-ms-date", now.ToString("R", CultureInfo.InvariantCulture));
      requestMessage.Headers.Add("x-ms-version", "2018-11-09");
    
      //your source path you want to rename
      requestMessage.Headers.Add("x-ms-rename-source", renameSourcePath);
    
      //rename operation only accept authorize by shared key via header
      requestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
      StorageGen2AccountName, StorageGen2AccountKey, now, requestMessage);

    Friday, September 6, 2019 9:22 AM
    Moderator
  • 

    Hi there,

    Just wanted to check - did the above suggestion help you ? If yes, please consider upvoting and/or marking it as answer. This would help other users reading this thread.

    Monday, September 16, 2019 8:33 AM
    Moderator