Forum Discussion

Nate's avatar
Nate
Occasional Contributor
3 years ago

Uploading app package using Invoke-RestMethod or Invoke-WebRequest

Attempting to upload my app to BitBar using Invoke-RestMethod or Invoke-WebRequest.

Getting " : The remote server returned an error: (500) Internal Server Error."

```

$package = 'c:\my.apk'
$bitbar = 'https://cloud.bitbar.com/api/me/files/'
$user = '<key>'
$pair = "$($user):"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{Authorization = $basicAuthValue}
Invoke-RestMethod -Method Post -Uri $bitbar -Headers $Headers -InFile $package -ContentType 'application/octet-stream'

```

I can successfully query using `Invoke-RestMethod -Method Get -Uri $bitbar -Headers $Headers`, so I know that authentication is working with $Headers and that the URL in $bitbar is valid.