REST API: Space

Post Reply
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

REST API: Space

Post by Dimix »

Sorry for a basic question, but I can't get it to work.

I'm using below to retrieve a dimension element list. Note that I'm selecting a specific attribute, 'BusinessUnit'.

/Dimensions('plan_business_unit')/Hierarchies('plan_business_unit')/Members('10000')?$expand=Children($select=Name, Attributes/BusinessUnit),Element($select=Name,Type,Attributes/BusinessUnit)

I now want to change this, select an attribute with a space in the name, e.g. 'Business Unit'.

/Dimensions('plan_business_unit')/Hierarchies('plan_business_unit')/Members('10000')?$expand=Children($select=Name, Attributes/Business Unit),Element($select=Name,Type,Attributes/Busines sUnit)

This is the error I get in Postman.

{
"error": {
"code": "278",
"message": "Syntax error at position 102, near \"Unit\" for $expand query option: Expecting ')' token."
}
}

I have tried different ways to get around this, e.g. replace the space with '%20', but nothing works.

Do you know how to fix this?
tomok
MVP
Posts: 2831
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: REST API: Space

Post by tomok »

I don't know the answer to your question but in SQL and MDX when you have blanks you have to encapsulate them in brackets. Maybe try
[Business Unit]???
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: REST API: Space

Post by Wim Gielis »

I would expect %20 as well, also given this page:
https://www.ibm.com/support/knowledgece ... chars.html
But I cannot get it to work either.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: REST API: Space

Post by Wim Gielis »

Also in 2.0.7 (server version 11.5) I get this error:

Code: Select all

{
error: {
code: "278",
message: "Syntax error at position 39, near "attribute" for $expand query option: Expecting ')' token."
}
}
for the URL:

Code: Select all

http://localhost:8001/api/v1/Dimensions('SGA_Account')/Hierarchies('SGA_Account')/Members('1000LONEN')?$expand=Children($select=Name,%20Attributes/test%20attribute),Element($select=Name,Type,Attributes/test%20attribute)
The attribute that I use is a text attribute called 'test attribute'.
I pasted the URL without %20 but with a space, the space is automatically converted to %20.

With an attribute without spaces it works fine.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: REST API: Space

Post by Dimix »

Thanks Wim and tomok. Maybe the easiest and quickest solution is to create an attribute without spaces.
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: REST API: Space

Post by Dimix »

Got an answer from Hubert Heijkers:

https://www.ibm.com/developerworks/comm ... 0d52&ps=25

Well, requests have to conform to OData URL conventions and therefore property names, in this case, the property name of the dynamic property representing the attribute has to be a valid OData identifier, and as such can not contain any spaces. So far the bad news.

The good news is that TM1, to a large extent (and in most places that's really inconvenient these days), case AND SPACE, insensitive and wherever it made sense we tried to apply that in the REST API too (not everywhere though, we have to know it is an identifier for an object which TM1 would internally have a find operation for that is case and space insensitive) so in this case, even if you add the space to the "Business Unit" attribute name you can still $select it by including Attributes/BusinessUnit. Even if you renamed it to "B uSi nEs s UnIt" it would still include it ;-). Note that in the response the property will actually use the formatting of the Attribute name (the judges are out on the ruling if that's actually OData compliant but that's what we went for anyway;-).
User avatar
macsir
MVP
Posts: 782
Joined: Wed May 30, 2012 6:50 am
OLAP Product: TM1
Version: PAL 2.0.9
Excel Version: Office 365
Contact:

Re: REST API: Space

Post by macsir »

Thanks for sharing. Yes, it works without any space for the attributes in REST even if the real attribute name has space in between in TM1.
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/
lotsaram
MVP
Posts: 3651
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: REST API: Space

Post by lotsaram »

Dimix wrote: Wed May 01, 2019 1:11 pm I now want to change this, select an attribute with a space in the name, e.g. 'Business Unit'.

/Dimensions('plan_business_unit')/Hierarchies('plan_business_unit')/Members('10000')?$expand=Children($select=Name, Attributes/Business Unit),Element($select=Name,Type,Attributes/Busines sUnit)

This is the error I get in Postman.

{
"error": {
"code": "278",
"message": "Syntax error at position 102, near \"Unit\" for $expand query option: Expecting ')' token."
}
}

I have tried different ways to get around this, e.g. replace the space with '%20', but nothing works.

Do you know how to fix this?
This was discussed about 1 year ago here.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
Post Reply