I have a requirement where i need to display Visual Studio online work items in SharePoint online. I am trying to do this via JQuery AJAX call. Here is my code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><script> var url="https://{account}/DefaultCollection/SCUBA/Interflow and TI/_apis/wit/wiql?api-version=1.0"; $( document ).ready(function() { var dataToSend = "{\"query\":\"Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.BoardColumn] in ('New','Active','Resolved','Closed') AND [System.WorkItemType] = 'User Story' AND [System.IterationPath] = 'SCUBA' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc\"}"; var jsonStr = JSON.stringify(dataToSend); debugger; $.ajax({ url: url, contentType: "application/json; charset=utf-8", type: 'GET', beforeSend: function(xhr) { xhr.setRequestHeader ("Authorization", "BEARER {personal access token}"); }, data: jsonStr, async:false, success: function(data){ alert('success'+data); }, error: function(jqXHR, textStatus, errorThrown) { alert('failed'+textStatus+" Error: "+errorThrown+jqXHR.status); } }); });</script>
I get a 200 success message but the response is returning HTML for sign in page. Please refer the below screen shot
Image may be NSFW.
Clik here to view.
How can i bypass this? since i have already provided the personal access toke it should return me a proper response. Please let me know hoe this can be handled?
Ujwal Seli | MCPD SharePoint 2010