This project has moved. For the latest updates, please go here.

Historian Web Service fails with multiple ID's

May 12, 2011 at 8:19 PM

I'm trying to retrieve historic data from the web service using many id's at once but there is a limit to how long the URL can be so a call like the following will fail:

http://localhost:6152/historian/timeseriesdata/read/historic/5,1,2,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155/05-12-11 20:09:11/05-12-11 20:14:11/json

because some of the URL is cut. Is there a way to submit the ID list via a POST command instead of in the URL? 

May 12, 2011 at 8:20 PM

EDIT: The web service returns the error "Bad Request (Invalid URL)"

Developer
May 12, 2011 at 8:26 PM

You can provide range instead of commna separated values e.g. 1-1000.

Mehul Thakkar

May 12, 2011 at 8:30 PM

This doesn't quite work for me, since I want the user to be able to exclude signals (ie select every other signal or select all except signal 36) there is no way to submit this data via a post?

May 12, 2011 at 10:45 PM

I fixed this problem by modifying the TVA.Historian Library I did the following:

 

added to ITimeSeriesDataService.cs:  

        [OperationContract(),
        WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/timeseriesdata/read/historic/json")]
        SerializableTimeSeriesData ReadSelectHistoricTimeSeriesDataAsJsonPost(SerializableReadRequestData data);

added to TimeSeriesDataService.cs:
       public SerializableTimeSeriesData ReadSelectHistoricTimeSeriesDataAsJsonPost(SerializableReadRequestData data)
        {
            string idString = "";
            if (data.idArray.Length > 0)
            {
                idString = data.idArray[0].ToString();
                for (int i = 1; i < data.idArray.Length - 1; i++)
                    idString = idString + "," + data.idArray[i];
            }
            return ReadHistoricTimeSeriesData(idString, data.startTime, data.endTime);
        }
created SerializableReadRequestData.cs:
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace TVA.Historian.DataServices
{
    /// 
    /// 
    /// 
    [XmlType("ReadRequestData"), DataContract(Name="ReadRequestData")]
    public class SerializableReadRequestData
    {
        public SerializableReadRequestData()
        {
        }

        [XmlArray(), DataMember(Order = 0)]
        public int[] idArray { get; set; }

        [XmlAttribute(), DataMember(Order = 1)]
        public string startTime { get; set; }
        
        [XmlAttribute(), DataMember(Order = 2)]
        public string endTime { get; set; }

    }
}


This allows for POST requests to be made to the path "/timeseriesdata/read/historic/json" in order to retrieve data.

Coordinator
May 13, 2011 at 12:40 PM

Thanks for the patch! We'll try to get this added in ASAP.

Ritchie

Coordinator
May 18, 2011 at 5:32 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.