Bitbucket API Invoke-RestMethod, Powershell, Get data to Json file,webscraping
<p>I try to do exact same thing that Bibucket API explained</p>

<p>BitBucket says/explain </p>

<p><a href="https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html" rel="nofollow">https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html</a></p>

<p>GET <a href="https://api.bitbucket.org/2.0/repositories/" rel="nofollow">https://api.bitbucket.org/2.0/repositories/</a>{owner}/{repo_slug}</p>

<pre><code>{
    "scm": "hg",
    "has_wiki": true,
    "description": "Site for tutorial101 files",
    "links": {
        "watchers": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/watchers"
        },
        "commits": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commits"
        },
        "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "html": {
            "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
            "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        },
        "forks": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/forks"
        },
        "clone": [{
            "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org",
            "name": "https"
        }, {
            "href": "ssh://hg@bitbucket.org/tutorials/tutorials.bitbucket.org",
            "name": "ssh"
        }],
        "pullrequests": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests"
        }
    },
    "fork_policy": "allow_forks",
    "name": "tutorials.bitbucket.org",
    "language": "html/css",
    "created_on": "2011-12-20T16:35:06.480042+00:00",
    "full_name": "tutorials/tutorials.bitbucket.org",
    "has_issues": true,
    "owner": {
        "username": "tutorials",
        "display_name": "tutorials account",
        "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/users/tutorials"
            },
            "html": {
                "href": "https://bitbucket.org/tutorials"
            },
            "avatar": {
                "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
            }
        }
    },
    "updated_on": "2014-11-03T02:24:08.409995+00:00",
    "size": 76182262,
    "is_private": false,
    "uuid": "{9970a9b6-2d86-413f-8555-da8e1ac0e542}"
}
</code></pre>

<p>I would like to do exact same thing by using powershell.</p>

<p>So, I made a code.</p>

<pre><code>$username = ""
$password = ""

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$response=Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Uri https://bitbucket.org/susco/azuretoquickbase -Method Get

$response
</code></pre>

<p>I am sure that I could log in bitbucket since I saw the content of " $responce".</p>

<p>then, like Bitbucket says, I added the code like this to echo out Json file .</p>

<pre><code> $username = ""
$password = ""

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$response=Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Uri https://bitbucket.org/susco/azuretoquickbase -Method Get

$response


$json = $response.Content|ConvertFrom-Json


$json.data.summaries
</code></pre>

<p>but it is causing error</p>

<pre><code>ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At line:11 char:27
+ $json = $response.Content|ConvertFrom-Json
+                           ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
</code></pre>

<p>The point is I am sure that I could log in and get to the page bitbucket says, but it is not getting json file and null error.</p>

<p>I want exactly to echo out like Bitbuckets page, How can i do that?</p>