View Extract with TM1 API

ture
Posts: 9
Joined: Sat Oct 21, 2017 11:40 am
OLAP Product: tm1
Version: 10.2
Excel Version: 2013

Re: View Extract with TM1 API

Post by ture » Fri Nov 03, 2017 11:28 am

Super! I can see that it works! Thank You!

I have last problem. When I use API for c/c++/basic and want to extract a content through my new MDX-view from this cube, I upload all content of cube.

For example:

Code: Select all

//cube by name
TM1V hCube = TM1ObjectListHandleByNameGet(hPool, hServer, TM1ServerCubes()       , TM1ValString(hPool, "}ClientGroups" , 0));
//view by name
TM1V hView = TM1ObjectListHandleByNameGet(hPool, hCube  , TM1ValIndex(hPool, 357), TM1ValString(hPool, "mdx_View_last9", 0));
				
//extract data from view
TM1V hExtractList = TM1ViewExtractCreate(hPool, hView);
TM1V hExtract = nullptr;
					
while (nullptr != (hExtract = TM1ViewExtractGetNext(hPool, hExtractList))) {
	if (TM1ValType(hUser, hExtract) == TM1ValTypeError()) 
		std::cerr << "Oops\n";
					
	TM1_INDEX ind = TM1ValType(hUser, hExtract);
	if (ind == TM1ValTypeIndex()) {
		TM1_INDEX n = TM1ValIndexGet(hUser, hExtract);
		if (n > 0) 
			std::cout << n << std::endl;
		else
			break;
	}else if (ind == TM1ValTypeString()) 
		std::cout << TM1ValStringGet(hUser, hExtract) << std::endl;
	else if (ind == TM1ValTypeReal()) 
		std::cout << TM1ValRealGet(hUser, hExtract) << std::endl;
	else
		std::cerr << "Oops 2\n";
}
But through Rest API it works fine:

Code: Select all

https://as-msk-a0134:8000/api/v1/Cubes('}ClientGroups')/Views('mdx_View_last9')/tm1.Execute?$expand=Cube($select=Name;$expand=Dimensions($select=Name)),Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)))),Cells
with headers certainly.

How can I extract data through mdx-view correctly using API c/++/basic?

Wim Gielis
MVP
Posts: 1826
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0
Excel Version: 2016
Location: Brussels, Belgium
Contact:

Re: View Extract with TM1 API

Post by Wim Gielis » Fri Nov 03, 2017 12:15 pm

ture wrote:
Fri Nov 03, 2017 11:28 am
But through Rest API it works fine:

Code: Select all

https://as-msk-a0134:8000/api/v1/Cubes('}ClientGroups')/Views('mdx_View_last9')/tm1.Execute?$expand=Cube($select=Name;$expand=Dimensions($select=Name)),Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)))),Cells
with headers certainly.
Hi,

Just a question. I changed the URL to:

Code: Select all

http://localhost:8000/api/v1/Cubes('CPI')/Views('a')/tm1.Execute?$expand=Cube($select=Name;$expand=Dimensions($select=Name)),Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)))),Cells
What does it mean if I receive in the browser (Chrome):

{"error":{"code":"278","message":"GET not supported on this resource!"}}

8000 is correct, so is cube CPI and view a.

Other statements with the REST API are fine.
Trying to increase my knowledge in this area :-)
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
http://www.wimgielis.com ==> 105 TM1 articles and a lot of custom code
Newest blog article: Looping over input files

ture
Posts: 9
Joined: Sat Oct 21, 2017 11:40 am
OLAP Product: tm1
Version: 10.2
Excel Version: 2013

Re: View Extract with TM1 API

Post by ture » Fri Nov 03, 2017 1:29 pm

Hi,

Just a question. I changed the URL to:

Code: Select all

http://localhost:8000/api/v1/Cubes('CPI')/Views('a')/tm1.Execute?$expand=Cube($select=Name;$expand=Dimensions($select=Name)),Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)))),Cells
What does it mean if I receive in the browser (Chrome):

{"error":{"code":"278","message":"GET not supported on this resource!"}}

8000 is correct, so is cube CPI and view a.



Other statements with the REST API are fine.
Trying to increase my knowledge in this area :-)
[/quote]

You need use "Postman" https://chrome.google.com/webstore/deta ... bncdddomop

Make POST to this URL.

Drg
Posts: 84
Joined: Fri Aug 12, 2016 10:02 am
OLAP Product: tm1
Version: 10.2.0 - 10.3.0
Excel Version: 2010

Re: View Extract with TM1 API

Post by Drg » Tue Nov 28, 2017 9:49 am

Use POST method.

Post Reply