Forum Discussion

Prefsmaster's avatar
Prefsmaster
Regular Visitor
9 years ago
Solved

Pushing data to PowerBI Streaming dataset API fails when historic data analysis is ON

The Topic says it all.

I have successfully created an API and was happily pushing events to it.

Then I created an Azure Webjob that pushes some random data every second or so.

Data flows nicely and I can see live gauges and line-charts!

Next, I enabled historic data analysis so I could try to visualize my events with a custom visual.

BOOM. Immediately I got 'Bad Request' failures:

Making POST request with data: {"timestamp":"2017-02-28T14:48:09.058","queuelength":75.0,"corridoroccupancy":8.0,"maxcorridor":10.0}
Exception thrown: 'System.Net.WebException' in System.dll
System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()

When I disable the historic analysis everything goes back to normal.

Anybody an idea of what I may be doing wrong?

Is there some data field that is mandatory when historic data is on?

If yes, where is that documented?

 

  • Eric_Zhang's avatar
    Eric_Zhang
    9 years ago

    Prefsmaster

    What is the JSON format in your case?
    In my test, before enabling "HISTORIC" I can upload data with 

    {
    "DATETM" :"2017-03-02T09:04:48.837Z",
    "SALES" :5000000
    }

    However after enabling "HISTORIC", I got a 400 error though the upload data would finally get saved as in your case. The reponse contains  the the error saying something wrong with the dataset JSON. In case you have interest, the tool is POSTMAN

     

    Based on my test, with a dataset JSON format as below could always work either the "HISTORIC" is enabled or disabled.

    [
    {
    "DATETM" :"2017-03-02T10:04:48.837Z",
    "SALES" :45000000
    } 
    ]

    You can actually send multiple data in JSON array.

    [
    {
    "DATETM" :"2017-03-02T10:04:48.837Z",
    "SALES" :45000000
    },
    
    {
    "DATETM" :"2017-03-01T09:04:48.837Z",
    "SALES" :38000000
    }
    ]

     

14 Replies

    • Prefsmaster's avatar
      Prefsmaster
      Regular Visitor

      Hi, I am using the endpoint copied from the PowerBI UI:

       

       

       

       

       

       

       

       

       

       

       

      And I wrote a small Command Line Tool to Send JSON to that endpoint (URL is stored in 'realTimePushURL'):

                  Debug.WriteLine($"Making POST request with data: {jsonString}");
      
                  var bodyData = Encoding.UTF8.GetBytes(jsonString);
      
                  WebRequest request = WebRequest.Create(realTimePushURL);
                  request.Method = "POST";
                  request.ContentLength = bodyData.Length;
      
                  var dataStream = request.GetRequestStream();
                  dataStream.Write(bodyData, 0, bodyData.Length);
                  dataStream.Close();
      
                  WebResponse response = request.GetResponse();

      I can send you the full source code of my small tool, but I think this won't help much: 

      The fact is that sending data to the streaming API with it works fine, as long as I don't turn on 'Historic data analysis' in PBI:

      Ferenc

       

       

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Prefsmaster,

         

        I try to turn off the 'Historic' and the tile still works well. Perhaps you can try to test with the above sample.

         

        Regards,

        Xiaoxin Sheng

    • Prefsmaster's avatar
      Prefsmaster
      Regular Visitor

      Afterthought: I know those articles you mention, andused them to get as far as I am now :-)

      I am now using this bit from the first referenc article you mention:

      I understood from the article that BOTH the URL and AAD approaches should work with an API created through the service UI.

      Perhaps it is wrong, and is it mandatory to use AAD auth when you want to use Historic data analysis.

       

      Ferenc