我有以下代码来创建一个JSON对象,然后将其发布到powerBI中的流数据集。到目前为止,我似乎找到了数据集和表格,但我在json对象上收到了一个错误的请求。在下面的代码中是否有一些简单的东西会阻止它工作?
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
var payload = new testValues
{
value1 = "test",
value2 = counter,
value3 = DateTime.UtcNow
};
string stringPayload = JsonConvert.SerializeObject(payload);
StringContent postContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
ODataResponseListDataset datasets = client.Datasets.GetDatasetsInGroup(GroupId);
client.Datasets.PostRowsInGroup(GroupId, datasets.Value.LastOrDefault().Id, "RealTimeData", postContent);
counter++;
return;
}
以下是testValues类,以防万一也可以解释我的问题:
public class testValues
{
[JsonProperty("value1")]
public string value1 { get; set; }
[JsonProperty("value2")]
public int value2 { get; set; }
[JsonProperty("value3")]
public DateTime value3 { get; set; }
}