2

I followed the Azure DevOps docs for how to create a Personal Access Token, convert the token to Base64 and GET repo branches, but I cannot successfully request.

What am I missing?

PowerAutomate Action: HTTP Request

  • Where myOrg, myProject and myRepoID are actual values

enter image description here

Error: 302 Redirect

enter image description here

Error Text:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://spsprodcus3.vssps.visualstudio.com/_signin?realm=dev.azure.com&amp;reply_to=https%3A%2F%2Fdev.azure.com%2FmyOrg%2FmyProject%2F_apis%2Fgit%2Frepositories%2FmyRepoID%2Frefs%3Fapi-version%3D6.0&amp;redirect=1&amp;hid=<longGUID>&amp;context=<longGUIDctx=<longGUID">here</a>.</h2>
</body></html>

EDIT 1:

  • Tried adding the Content-Type header and adding the auth as a special header
  • Still same error

enter image description here

EDIT 2:

  • Tried adding the PAT to Basic auth but the Username is required

enter image description here

EDIT 3:

  • I found that even though above action fails, the response Location header contains a URL that resolves correctly:

    • https://spsprodcus3.vssps.visualstudio.com/_signin?realm=dev.azure.com&reply_to=https%3A%2F%2Fdev.azure.com%2FmyOrg%2FmyProject%2F_apis%2Fgit%2Frepositories%3Fapi-version%3D6.0&redirect=1&mkt=en-US&hid=LONG_GUID&context=LONG_GUIDctx=LONG_GUID
  • BUT when this URL is piped to a subsequent HTTP action, it results in a 203 response that does not include the REST response!

enter image description here

EDIT 4: THIS WORKED

  • Added a . to the Basic username Authentication
  • Regenerated the ADO Personal Access Token, saved the new value in Key Vault

enter image description here

SeaDude
  • 3,725
  • 6
  • 31
  • 68
  • 1
    Try to change Authentication to `Basic Auth` and add your PAT as the password. Username can be blank – GeralexGR Feb 28 '22 at 08:42
  • Hm. @GeralexGR, Username can not be blank. See **EDIT 1** above – SeaDude Feb 28 '22 at 16:13
  • 1
    Enter `.` as the username. The value is ignored. – jessehouwing Feb 28 '22 at 21:57
  • Just tested, please see **EDIT 4** in OP. Same response as putting the `Authorization Bearer `: Redirect 312. How can I get a JSON response from the Azure DevOps REST API? – SeaDude Feb 28 '22 at 22:01
  • 1
    EH...regenerated the Personal Access Token, saved it as a new version of Key Vault secret, re-submitted the flow...works! No redirects, nothing, just a nice, clean, **Status 200**! Go ahead and write up the answer and I'll award the bounty. – SeaDude Feb 28 '22 at 22:17

1 Answers1

4

Thank you @GeralexGR and @jessehouwing , @SeaDude as you have confirmed your solution ,I am posting it as an answer to help other Community members for the similar issue so they can find and fix their issue as you have mentioned in comment.

I followed the Azure DevOps docs for how to create a Personal Access Token, convert the token to Base64 and GET repo branches, but I cannot successfully request.

What am I missing?

To achieve the above requirement try to add Authentication as BASIC and user add . .

And

Regenerate ADO Personal Access Token and save the new value in your Key Vault secret and resubmit flow.

enter image description here

For more information please refer this MICROSOFT DOCUMENTATION.

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15
  • 2
    Technically, the bounty should be @jessehouwing's. But since he didn't write up an answer after 5 days, you can have it. – SeaDude Mar 05 '22 at 02:06
  • Username can be empty. The important thing is to convert the string `:` in base 64 (note the `:` at the beginning of the string) – Krusty Sep 01 '22 at 21:51