Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

how to write schema this data in json format for post dataset in power bi rest api

 {
            "reportRefreshDate""2022-02-25",
            "userPrincipalName": "[email protected]",
            "displayName""xyz",
            "isDeleted"false,
            "deletedDate"null,
            "lastActivityDate""2022-02-25",
            "sendCount"0,
            "receiveCount"3,
            "readCount"3,
            "meetingCreatedCount"0,
            "meetingInteractedCount"0,
            "assignedProducts": [
                "MUSIC",
                "MICROSOFT "
            ],
            "reportPeriod""7"
        },
 
 
I want to write a schema for creating a dataset  using the above data
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

    You can write the schema as follow and run the REST API Push Datasets - Datasets PostDataset to create the dataset first:

     

    {
      "name": "Reportview",  //dataset name
      "defaultMode": "Push", 
      "tables": [
        {
          "name": "reporttrack", //table name
          "columns": [
            {
              "name": "reportRefreshDate",
              "dataType": "DateTime"
            },
            {
              "name": "userPrincipalName",
              "dataType": "string"
            },
            {
              "name": "displayName",
              "dataType": "string"
            },
            {
              "name": "isDeleted",
              "dataType": "bool"
            },
    		 {
              "name": "deletedDate",
              "dataType": "DateTime"
            },
    		 {
              "name": "lastActivityDate",
              "dataType": "DateTime"
            },
    			 {
              "name": "sendCount",
              "dataType": "Int64"
            },
    			 {
              "name": "receiveCount",
              "dataType": "Int64"
            },
    			 {
              "name": "readCount",
              "dataType": "Int64"
            },
    		  {
              "name": "meetingCreatedCount",
              "dataType": "Int64"
            },
    		  {
              "name": "meetingInteractedCount",
              "dataType": "Int64"
            },
            {
              "name": "assignedProducts",
              "dataType": "string"
            },
            {
              "name": "reportPeriod",
              "dataType": "Int64"
            }
          ]
        }
      ]
    }

     

    Then run the REST API Push Datasets - Datasets PostRows using the below json data to add the rows into the table in above new created dataset.

     

    {
      "rows": [
        {
          "reportRefreshDate": "2022-02-25",
                "userPrincipalName": "[email protected]",
                "displayName": "xyz",
                "isDeleted": false,
                "deletedDate": null,
                "lastActivityDate": "2022-02-25",
                "sendCount": 0,
                "receiveCount": 3,
                "readCount": 3,
                "meetingCreatedCount": 0,
                "meetingInteractedCount": 0,
                "assignedProducts": "MUSIC",
                "reportPeriod": "7"
        }, {
          "reportRefreshDate": "2022-02-25",
                "userPrincipalName": "[email protected]",
                "displayName": "xyz",
                "isDeleted": false,
                "deletedDate": null,
                "lastActivityDate": "2022-02-25",
                "sendCount": 0,
                "receiveCount": 3,
                "readCount": 3,
                "meetingCreatedCount": 0,
                "meetingInteractedCount": 0,
                "assignedProducts": "MICROSOFT"  ,
                "reportPeriod": "7"
        }
      ]
    }

     

    Best Regards

4 Replies

  • I am not aware of a "Post dataset"  API call.  What you list looks more like a table/partition.  Please explain what you are trying to accomplish. Do you mean Push datasets?

    • Anonymous's avatar
      Anonymous
      Not applicable

      I am using Push dataset rest api  and i  am trying to post the above dataset schema

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        You can write the schema as follow and run the REST API Push Datasets - Datasets PostDataset to create the dataset first:

         

        {
          "name": "Reportview",  //dataset name
          "defaultMode": "Push", 
          "tables": [
            {
              "name": "reporttrack", //table name
              "columns": [
                {
                  "name": "reportRefreshDate",
                  "dataType": "DateTime"
                },
                {
                  "name": "userPrincipalName",
                  "dataType": "string"
                },
                {
                  "name": "displayName",
                  "dataType": "string"
                },
                {
                  "name": "isDeleted",
                  "dataType": "bool"
                },
        		 {
                  "name": "deletedDate",
                  "dataType": "DateTime"
                },
        		 {
                  "name": "lastActivityDate",
                  "dataType": "DateTime"
                },
        			 {
                  "name": "sendCount",
                  "dataType": "Int64"
                },
        			 {
                  "name": "receiveCount",
                  "dataType": "Int64"
                },
        			 {
                  "name": "readCount",
                  "dataType": "Int64"
                },
        		  {
                  "name": "meetingCreatedCount",
                  "dataType": "Int64"
                },
        		  {
                  "name": "meetingInteractedCount",
                  "dataType": "Int64"
                },
                {
                  "name": "assignedProducts",
                  "dataType": "string"
                },
                {
                  "name": "reportPeriod",
                  "dataType": "Int64"
                }
              ]
            }
          ]
        }

         

        Then run the REST API Push Datasets - Datasets PostRows using the below json data to add the rows into the table in above new created dataset.

         

        {
          "rows": [
            {
              "reportRefreshDate": "2022-02-25",
                    "userPrincipalName": "[email protected]",
                    "displayName": "xyz",
                    "isDeleted": false,
                    "deletedDate": null,
                    "lastActivityDate": "2022-02-25",
                    "sendCount": 0,
                    "receiveCount": 3,
                    "readCount": 3,
                    "meetingCreatedCount": 0,
                    "meetingInteractedCount": 0,
                    "assignedProducts": "MUSIC",
                    "reportPeriod": "7"
            }, {
              "reportRefreshDate": "2022-02-25",
                    "userPrincipalName": "[email protected]",
                    "displayName": "xyz",
                    "isDeleted": false,
                    "deletedDate": null,
                    "lastActivityDate": "2022-02-25",
                    "sendCount": 0,
                    "receiveCount": 3,
                    "readCount": 3,
                    "meetingCreatedCount": 0,
                    "meetingInteractedCount": 0,
                    "assignedProducts": "MICROSOFT"  ,
                    "reportPeriod": "7"
            }
          ]
        }

         

        Best Regards