-1

I was able to access vsrm.dev.azure.com API via $.ajax.get calls i.e. https://vsrm.dev.azure.com/microsoft/***/_apis/release/definitions/****

Now I'm starting to get CORS error: Access to XMLHttpRequest at 'https://vsrm.dev.azure.com/microsoft//_apis/release/definitions/' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any ideas how to fix this?

IlanKogan
  • 137
  • 1
  • 9
  • Does this answer your question? [XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header](https://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-xxx-no-access-control-allow-origin-header) – Quentin Mar 18 '20 at 07:58
  • 1
    Exact same thing happened to me, turned out my personal access token had expired – DJM Mar 22 '20 at 19:21

1 Answers1

0

The ajax get still work for me now without any error message. Since you did not share any code of yours, here I just provide you mine:

<script type="text/javascript">
    $(document).ready(function () {
        $("#click").on("click", function () {
            $.ajax({
                type: 'GET',
                url: 'https://vsrm.dev.azure.com/{org}/{project name}/_apis/release/definitions/{id}?api-version=5.1',
                cache: false,
                dataType: 'json',
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("Authorization", "Basic " + btoa("" + ":" + "{PAT token}"));
                },
            }).done(function (data) {
                alert(data);
            }).error(function (e) {
                var s = "error error error";
            });
        })
    });
</script>

You can try with mine to see whether it is work for you.


Update:

I cover my org name, project name, release definition id and my PAT token in my script, please replace it with your available values.

enter image description here

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35