AngularJS 2调用Sharepoint Web服务

时间:2016-12-14 02:24:44

标签: json rest angular sharepoint

以下代码抛出错误,Web服务调用似乎没有返回json ....

private _url =“https://us.sharepoint.com/sites/poc/_api/web/lists/getbytitle('”+“Micro”+“')/ items”;

constructor(private http: Http) { }

getCMPosts() {
    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Accept', 'application/json;odata=verbose');
    this._url = "https://us.sharepoint.com/sites/poc/_api/web/lists/getbytitle('" + "Micro" + "')/items";
    console.log("URL 1: " + "https://us.sharepoint.com/sites/poc/_api/web/lists/getbytitle('" + "Micro" + "')/items");
    return this.http.get("https://us.sharepoint.com/sites/poc/_api/web/lists/getbytitle('" + "Micro" + "')/items", headers)
        .map(this.extractData)
}

private extractData(res: Response) {
    console.log("URL 2: " + "https://us.sharepoint.com/sites/poc/_api/web/lists/getbytitle('" + "Micro" + "')/items")
    console.log("Response Status: " + res.status);
    console.log("res.headers: " + res.headers);
    console.log("Response Text: " + res.text);
    console.log("Response To String: " + res.toString());
    let body = res.json();
    return body.data || {};
}

图像错误请检查 Error Screen Shot

0 个答案:

没有答案