コード例 #1
0
        /// <summary>
        /// Updates the dataset schema
        /// </summary>
        /// <param name="datasetId"></param>
        /// <param name="datasetSchema"></param>
        /// <returns>Http Response from Dataset Metadata request</returns>
        public async Task <HttpResponseMessage> UpdateDatasetMetadataAsync(string datasetId, IDatasetSchema schema)
        {
            string datasetUri = $"v1/datasets/{datasetId}";

            _domoHttpClient.SetAcceptRequestHeaders("application/json");
            DatasetSchema correctSchema = new DatasetSchema()
            {
                Description = schema.Description, Rows = schema.Rows, Name = schema.Name, Schema = schema.Schema
            };
            string        schemaJson = JsonConvert.SerializeObject(correctSchema, _serializerSettings);
            StringContent content    = new StringContent(schemaJson, Encoding.UTF8, "application/json");

            var response = await _domoHttpClient.Client.PutAsync(datasetUri, content);

            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Creates a dataset in DOMO with the specified schema. Does not populate dataset with data.
        /// </summary>
        /// <param name="schema"></param>
        /// <returns>Dataset object with newly created dataset information</returns>
        public async Task <Dataset> CreateDatasetAsync(IDatasetSchema schema)
        {
            string datasetUri = "v1/datasets";

            _domoHttpClient.SetAcceptRequestHeaders("application/json");
            DatasetSchema correctSchema = new DatasetSchema()
            {
                Description = schema.Description, Rows = schema.Rows, Name = schema.Name, Schema = schema.Schema
            };
            string        schemaJson = JsonConvert.SerializeObject(correctSchema, _serializerSettings);
            StringContent content    = new StringContent(schemaJson, Encoding.UTF8, "application/json");
            var           response   = await _domoHttpClient.Client.PostAsync(datasetUri, content);

            string responseMessage = await response.Content.ReadAsStringAsync();

            var newDataset = JsonConvert.DeserializeObject <Dataset>(responseMessage);

            return(newDataset);
        }