Sample code to access Gen2 REST api


  • Hi,

    for the Gen2 api, we have the following link describing the operations.

    But it does not include examples of how to make each call.

    Do any examples exist yet? (C# code, etc.)

    If so can you please share the links?


    Monday, March 4, 2019 12:08 AM

All replies

  • Hi there,

    These are the Rest APIs for the data lake storage gen2 operations. REST APIs can be invoked anywhere and in any way based on your use case. For example - To invoke REST APIs from C#, please follow this :

    You can basically invoke these REST APIs and parse and use the responses in your client code to tailor to your use case.

    Hope this helps.


    Monday, March 4, 2019 9:39 AM
  • ok I understand what you are saying that it is just like any other REST api.

    But if you see similar documents for the previous versions (Blob REST api, etc.), you can see that there is actual sample code provided in the same documents, and even other pages related to it - like the following

    at the bottom of this page you can see "sample code".

    So that is what I was asking about whether something like this exists yet for Gen2.


    Monday, March 4, 2019 1:45 PM
  • Hi there,

    Sorry for the delayed response. I got in touch with the Team and got some examples for you :

    Create a file system

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$"

    Once complete, the server returns a 201 Created response.

    Create a directory

    To create a directory in the file system, use the following command:

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$"

    Create a file

    Next, issue some PUT commands to the server to create a few files. Make sure to create both files as each are used in subsequent examples.

    curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$"curl -i -X PUT -H "x-ms-version: 2018-11-09" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN""https://$"

    Once complete, the server returns a 201 Created response for each command.

    Hope this helps!


    Wednesday, March 20, 2019 10:44 AM
  • Hello,

    I can not send content to a file from rest api
    Do you have a sample code to use the PUT RANGE method ?


    Tuesday, April 23, 2019 2:32 PM
  • Hi BBHekD,

    Do you want to write to a file on ADLS Gen2 using the REST APIs? If yes, please refer to this thread for a step by step guide for the same.


    Monday, April 29, 2019 9:51 AM