Page 1 of 1
REST API: Space
Posted: Wed May 01, 2019 1:11 pm
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?
Re: REST API: Space
Posted: Wed May 01, 2019 2:56 pm
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]???
Re: REST API: Space
Posted: Wed May 01, 2019 3:01 pm
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.
Re: REST API: Space
Posted: Thu May 02, 2019 12:32 pm
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.
Re: REST API: Space
Posted: Thu May 02, 2019 12:36 pm
by Dimix
Thanks Wim and tomok. Maybe the easiest and quickest solution is to create an attribute without spaces.
Re: REST API: Space
Posted: Fri May 03, 2019 4:14 am
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;-).
Re: REST API: Space
Posted: Fri May 03, 2019 4:49 am
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.
Re: REST API: Space
Posted: Fri May 03, 2019 7:16 am
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.