0
現在、POSTからBSON応答を返すWeb APIがあります。BSAPをWebAPIのクライアント内のオブジェクトに限定する
通常、私はJSONを返すWebAPIを持っています。これをクライアントで行い、C#オブジェクトまたはオブジェクトに逆シリアル化します。私は今、BSON応答を得るためにこれをやっている
var result = await GetApiClient().PostAsJsonAsync("api/Test/GetImages", args);
if (result.IsSuccessStatusCode)
return await result.Content.ReadAsAsync<T>();
:コンテンツを読み込むとき
MediaTypeFormatter bsonFormatter = new BsonMediaTypeFormatter();
var result = await GetApiClient().PostAsync("api/Test/GetImages", args, bsonFormatter);
if (result.IsSuccessStatusCode)
return await result.Content.ReadAsAsync<T>();
JSONが正常に動作しますが、BSONエラー:
No MediaTypeFormatter is available to read an object of type IEnumerable1 from content with media type 'application/bson'
私は100%です私はBSONを取り戻していますが、オブジェクトに逆シリアル化する方法はまだ分かりません。