Forum Discussion
Streaming Data using API
Thank you for your help.
I read the guide from your url https://github.com/Microsoft/PowerBI-CSharp/tree/master/samples/consoleapp/getting-started-for-dotnet-real-time
Can I just check, for step 5 and 6, do I need to type the field name as "ts" and "value"? Can I use "Actual departure/arrival times", "Delay calculations", and "Equipment type" instead?
For step 9, what does it mean by "copy the sample app locally"? Where do I get the sample app?
Hi sengyap,
For step 9, what does it mean by "copy the sample app locally"? Where do I get the sample app?
You can download the sample app here.
Can I just check, for step 5 and 6, do I need to type the field name as "ts" and "value"? Can I use "Actual departure/arrival times", "Delay calculations", and "Equipment type" instead?
To illustrate the sample app, you need to type the field name as "ts" and "value", because it is hard coded in the sample app as below:
// Send POST request to the push URL
// Uses the WebRequest sample code as documented here: https://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx
WebRequest request = WebRequest.Create(realTimePushURL);
request.Method = "POST";
string postData = String.Format("[{{ \"ts\": \"{0}\", \"value\":{1} }}]", currentTime, currentValue);
Console.WriteLine(String.Format("Making POST request with data: {0}", postData));
// Prepare request for sending
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();If you want to use "Actual departure/arrival times", "Delay calculations", and "Equipment type" instead, you need to rewrite your own app correspondingly.
Regards
- sengyap9 years agoHelper I
Hi v-ljerr-msft,
Thank you for sending me the sample app file, but there are quite a few documents in the file, which one do I use? Do I need any external program to run the sample app?
Regards
- v-ljerr-msft9 years agoMicrosoft Employee
Hi sengyap,
- Go to app.powerbi.com
- Go to streaming data management page by via new dashboard > Add tile > Custom Streaming Data > manage data
- Click "Add streaming dataset"
- Select API, then Next, and give your streaming dataset a name
- Add a field with name "ts", type DateTime
- Add a field with name "value", type Number
- Click "Create"
- Copy the "push URL" at the top of the page
- Copy the sample app locally, and in Program.cs, paste url copied in step 8 as the value of "realTimePushURL"
- Run the sample app
- With the sample app running, go to the dashboard, and create a real-time tile with with the data provided by the sample app
Yes, you need to run the sample app with your Visual Studio locally by selecting "PBIRealTimeStreaming.sln" in "PowerBI-CSharp-master\samples\consoleapp\getting-started-for-dotnet-real-time\PBIRealTimeStreaming" folder.:smileyhappy:
Regards
- sengyap9 years agoHelper I
v-ljerr-msft Do I need to run the sample app everytime to load the API or will it automatically update itself?