It's all about the answers!

Ask a question

How to create a category with '&' in title using REST API.


Srinivasarao A (633) | asked Jun 03 '14, 11:35 a.m.
 I am trying to create categories using REST API.
I am having issue when the category title has '&' like <title>Andaman & Nicobar Islands</title>.
If I use & in request XML, i am getting parsing error and if i use  '&amp;', i am getting Response code 400.

Any idea to fix this issue? Thanks in Advance.
 

Comments
Donald Nong commented Jun 04 '14, 3:22 a.m. | edited Jun 04 '14, 3:22 a.m.

If you create such category via the web UI and the GET it using REST API, what is the RDF/XML representation of the title?
Also, out of curiosity, how exactly did you create a category using REST API?

One answer



permanent link
Piotr Aniola (3.7k11738) | answered Jun 03 '14, 11:47 a.m.
Did you try to replace '&' with the corresponding entity? That would be &amp;

Comments
Srinivasarao A commented Jun 03 '14, 2:17 p.m.

I need to add title like <title>Andaman & Nicobar</title>. The character i need is & itself, not '&'.



Simon Washbrook commented Jun 04 '14, 3:47 a.m.

Hi Srinivasarao, What Piotr is trying to say is that the ampersand character is a special character so you need to replace it with a HTML entity, which is a special encoding. You will notice that HTML entities all start with the ampersand character. See the link "http://www.w3schools.com/html/html_entities.asp" and search for ampersand.
You will need to use <title>Andaman &amp; Nicobar</title>to pass the ampersand character.
Simon


Piotr Aniola commented Jun 04 '14, 10:47 a.m.

Ok, I just noticed that when I typed the ampersand entity, the forum parsed it and rendered the actual ampersand instead. This obviously made my answer confusing, sorry.
As Simon said, the entity should be & amp ; without the spaces.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.