cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
tsherwood
Regular Visitor

REST API Post rows to dependent table?

I have created a dataset via REST that has four tables: A, B, C, D. Table B has a dependent relationship on A, and D has a dependent relationship on B & C.

 

I wrote a program to load the data in the following order: A, C, B, D. The program loads A & C fine, but times out trying to load B. When I remove the relationships all four tables load fine.

 

Is there a better way to load dependent tables?

1 ACCEPTED SOLUTION

Accepted Solutions
tsherwood
Regular Visitor

Re: REST API Post rows to dependent table?

I discovered the error to be failure to close the previous response object. For your reference, documentation on setting up table relationships (as well as other properties) in datasets can be found at https://msdn.microsoft.com/en-us/library/mt742155.aspx.

 

Here is sample JSON for a dateset I used to test:

 

{

"name": "SampleData",

"tables": [

{

"name": "TABLE_A",

"columns": [

{ "name": "PRIMARY_KEY_A", "dataType": "string", "isHidden": "true" },

{ "name": "CUSTOMER_NAME", "dataType": "string" },

{ "name": "CUSTOMER_ID", "dataType": "Int64", "summarizeBy": "sum", "formatString": "#,##0;(#,##0)" },

{ "name": "SALES", "dataType": "Decimal", "summarizeBy": "sum", "formatString": "$#,##0;($#,##0)" }

]

},

{

"name": "TABLE_B",

"columns": [

{ "name": "FOREIGN_KEY_A", "dataType": "string", "isHidden": "true" },

{ "name": "CITY", "dataType": "string", "summarizeBy": "none" }

]

}

],

"relationships": [

{

"name": "TABLE_B_TABLE_A_REL",

"crossFilteringBehavior": "BothDirections",

"fromTable": "TABLE_B",

"fromColumn": "FOREIGN_KEY_A",

"toTable": "TABLE_A",

"toColumn": "PRIMARY_KEY_A"

}

]

}

 

View solution in original post

3 REPLIES 3
Microsoft Eric_Zhang
Microsoft

Re: REST API Post rows to dependent table?


@tsherwood wrote:

I have created a dataset via REST that has four tables: A, B, C, D. Table B has a dependent relationship on A, and D has a dependent relationship on B & C.

 

I wrote a program to load the data in the following order: A, C, B, D. The program loads A & C fine, but times out trying to load B. When I remove the relationships all four tables load fine.

 

Is there a better way to load dependent tables?


@tsherwood

"B has dependent relationship on A", can you ensure that every referenced rows in A from B are imported before pushing data to B?

By the way, I'm not aware of the API creating dataset with tables in relationship, could you give me a demo or link?

tsherwood
Regular Visitor

Re: REST API Post rows to dependent table?

I discovered the error to be failure to close the previous response object. For your reference, documentation on setting up table relationships (as well as other properties) in datasets can be found at https://msdn.microsoft.com/en-us/library/mt742155.aspx.

 

Here is sample JSON for a dateset I used to test:

 

{

"name": "SampleData",

"tables": [

{

"name": "TABLE_A",

"columns": [

{ "name": "PRIMARY_KEY_A", "dataType": "string", "isHidden": "true" },

{ "name": "CUSTOMER_NAME", "dataType": "string" },

{ "name": "CUSTOMER_ID", "dataType": "Int64", "summarizeBy": "sum", "formatString": "#,##0;(#,##0)" },

{ "name": "SALES", "dataType": "Decimal", "summarizeBy": "sum", "formatString": "$#,##0;($#,##0)" }

]

},

{

"name": "TABLE_B",

"columns": [

{ "name": "FOREIGN_KEY_A", "dataType": "string", "isHidden": "true" },

{ "name": "CITY", "dataType": "string", "summarizeBy": "none" }

]

}

],

"relationships": [

{

"name": "TABLE_B_TABLE_A_REL",

"crossFilteringBehavior": "BothDirections",

"fromTable": "TABLE_B",

"fromColumn": "FOREIGN_KEY_A",

"toTable": "TABLE_A",

"toColumn": "PRIMARY_KEY_A"

}

]

}

 

View solution in original post

Microsoft Eric_Zhang
Microsoft

Re: REST API Post rows to dependent table?

Thanks for sharing. It looks the API reference documentation is updated, I didn't find such relationship before. Thanks again. 🙂

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors