我写了一个Java rest api,并包含了推URL来推送流数据。问题是,当创建报表时,它们为空白或为空!有什么我想念的吗?我是Power BI的业余爱好者。
public static void main(String args[]) throws IOException, InterruptedException
{
MongoClient mongo = new MongoClient("ip", 27017);
String push_url = "https://api.powerbi.com/beta/950bde67-19db-467b-
9a41-f80b7cf24ecb/datasets/dde28014-bf2a-46b3-830a-881144a2aec/rows?
key="vQbtAll96T4lJ9OgYBK1MEB6z4IPMOzOyLzkPUM05%2Fzk%2B
1l1S2fezWEKdJA%3D%3D";
DB db = mongo.getDB("test");
DBCollection table = db.getCollection("collection");
DBCursor cursor = table.find();
while(cursor.hasNext()) {
BasicDBObject document = new BasicDBObject();
BasicDBObject header = (BasicDBObject) cursor.next().get("header");
Object number = header.get("number");
BasicDBObject data = (BasicDBObject) cursor.next().get("data");
BasicDBList list = (BasicDBList) ((DBObject) data.get("transaction"));
for (int i = 0; i < list.size(); i++) {
BasicDBObject transaction = (BasicDBObject) list.get(i);
Object transactionID = transaction.get("transactionID");
document.put("number", number);
document.put("transaction", transactionID);
URL url = new URL(push_urls);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(String.valueOf(document));
out.flush();
}
}
}