のJSONとしてリスト項目を取得し、私は、XML/Atomフォーマット内のすべてのデータを見ることができる午前、 私はブラウザで、リストのリンクを入力すると代わりにXML /原子
下のスクリーンショット私は検索し、この流入を作るためにJSONとしての応答私は "RequestOptionsArgs"(私はTypescript & Angular2を使用しています)オブジェクトを使用しましたが、今回はリストの内容はありませんが、msg "Microsoft.SharePoint.SPException"というメッセージがあります。それは無効な認証を言う..しかし、私はすでにXMLコンテンツの中にデータを見ることができる応答データ形式を変更しようとしました。ここに私のサービスと消費方法;
import {Http,RequestOptionsArgs,Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import {Injectable} from '@angular/core';
@Injectable()
export class ListService {
constructor(private http_: Http){}
getAnnouncements(urllapi){
urllapi = "http://urll/_api/web/lists/getByTitle('Announcement5Jan')/items";
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');
let opts:RequestOptionsArgs = { headers: headers };
return this.http_.get(urllapi/*, opts */).map(res=>res.json());
//getting data as xml with this. if I comment out opts parameter no data but sp.exception
}
}
が呼び出されます。
this.spotfyService.getAnnouncements("").subscribe((res) => {
debugger
console.log("data:"+res)});
これらのアイテムはどのようにリザルトで取得できますか?
xmlまたはjsonにしたいですか? – Aravind
こんにちは、そのxmlは既に、私はそれがマッピングコードはどこですか?オブジェクトはあなたがマッピングしている – TyForHelpDude
jsonとしてそれが必要ですか? – Aravind