I'm having trouble running DevOps API's via 'az rest' The two methods I attempted return the same result
The code snippet I'm working with
$resource = "https://graph.microsoft.com"
$uribase = "https://dev.azure.com/{org}/{project}"
$requestpath = "/_apis/build/builds?api-version=6.0-preview.6"
$uri = $uribase+$requestpath
az rest --uri $uri --headers "Content-Type=application/json" --resource $resource
I've tried several different API versions down to 5.1 but the result is the same. If i remove the --resource parameter it complains about not being able to determine the authentication. Is 'https://graph.microsoft.com' the right resource for this call?
The error returned
> az : Not a json response, outputting to stdout. For binary data suggest use "--output-file" to
write to a file
At line:5 char:1
+ az rest --uri $uri --headers "Content-Type=application/json" --resour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Not a json resp...write to a file:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The command failed with an unexpected error. Here is the traceback:
'charmap' codec can't encode character '\u221e' in position 6302: character maps to <undefined>
Traceback (most recent call last):
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-
packages\azure\cli\command_modules\util\custom.py", line 18, in rest_call
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-yh2ypeu1\requests\requests\models.py", line
897, in json
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
....
I've written the output to a file. It's an HTML file that is related to sign in/sign out - nothing obvious from the text, but kindof a clue. As a result, I've been attempting to explicitly login to devops (even though I am logged in via 'az login') like this:
az devops login --organization https://dev.azure.com/{org}
The login hangs every time, I have to shut down powershell to restart. I've rebooted my machine, tried with and without the organization parameter, tried re-logging in via az login which works fine, but I cannot get the devops login command to work.
I'm not sure if the login is the issue or if its something else. Anyone else seen a situation like this? Thoughts on what to try?