locked
file storage service api to return json response RRS feed

  • Question

  • How can I change the below return json response, works fine and returns xml.

    $accountname="abcd-change to accountname"
    $key = "xyz-change to storage key"
    $Operation = "GET"


    $RESTAPI_URL = "https://$accountname.file.core.windows.net/?comp=list";

    $date=(Get-Date).ToUniversalTime()
    $datestr=$date.ToString("R");



    $strtosign = "$Operation`n`n`n`n`n`n`n`n`n`n`n`n`x-ms-date:$datestr`nx-ms-version:2018-03-28`n/"
    $strtosign = $strtosign + $accountname + "/"
    $strtosign = $strtosign + "`ncomp:list"

     

    echo $strtosign

     

    [byte[]]$dataBytes = ([System.Text.Encoding]::UTF8).GetBytes($strtosign)

    $hmacsha256 = New-Object System.Security.Cryptography.HMACSHA256

    $hmacsha256.Key = [Convert]::FromBase64String($key)

    $sig = [Convert]::ToBase64String($hmacsha256.ComputeHash($dataBytes))

    $authhdr = "SharedKey $accountname`:$sig"

     

    echo $authhdr

     

    $RequestHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

     

    $RequestHeader.Add("Authorization", $authhdr)
    $RequestHeader.Add("x-ms-date", $datestr)
    $RequestHeader.Add("x-ms-version", "2018-03-28")


    $RESTResponse = New-Object PSObject;


    echo $RESTAPI_URL
    echo $RequestHeader

     $RESTResponse = (Invoke-RestMethod -Uri $RESTAPI_URL -Method get -Headers $RequestHeader);

    echo $RESTResponse

    Wednesday, August 29, 2018 7:57 PM

Answers

  • As per the documentation, the response will always be application/xml.

    For more information, suggest you to refer the following document for better understanding of Response.


    Let me know if there are still any additional questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    • Proposed as answer by VeeraGiri Babu Thursday, August 30, 2018 5:52 AM
    • Marked as answer by jjamesj Thursday, August 30, 2018 12:57 PM
    Thursday, August 30, 2018 5:47 AM

All replies

  • As per the documentation, the response will always be application/xml.

    For more information, suggest you to refer the following document for better understanding of Response.


    Let me know if there are still any additional questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    • Proposed as answer by VeeraGiri Babu Thursday, August 30, 2018 5:52 AM
    • Marked as answer by jjamesj Thursday, August 30, 2018 12:57 PM
    Thursday, August 30, 2018 5:47 AM
  • Can you pleasehelp me on how to form $strtosign  for create-file api as per https://docs.microsoft.com/en-us/rest/api/storageservices/create-file
    Friday, August 31, 2018 12:35 AM
  • Every request made against a storage service must be authorized, unless the request is for a blob or container resource that has been made available for public or signed access. One option for authorizing a request is by using Shared Key.

    For more details, referAuthorize with Shared Key”.

    Friday, August 31, 2018 6:52 AM
  • Checking in to see if the above suggestions helped or you need further assistance on this issue. If that answers your query, do click “Mark as Answer” and Up-Vote for the same.
    Monday, September 3, 2018 7:10 AM