Can a player use the contact other plane spell to get a demon's true name?
Role-playing Games Stack Exchange is a question and answer site for gamemasters and players of tabletop, paper-and-pencil role-playing games. It only takes a minute to sign up.Sign up to join this community
Based on the answer to this question it seems your DM could decide to allow you to contact a particular named entity with the contact other plane spell.
But since the spell description says nothing about forcing or guaranteeing a truthful answer, your best chance is to get the answer from another entity who knows a demon’s name and can be relied upon to tell it to you truthfully.
Toward this end, your DM might make you pass History, Arcana and/or Religion checks to know the name of a long-dead sage who (1) has a likelihood of possessing the requisite knowledge (of a demon’s true name) and (2) who is likely to be compliant and truthful to the questioning enabled by your casting contact other plane (perhaps based on their alignment and their connection to you via the plot or backstory of your adventure, e.g. were they a member of your faction 100 years ago and would sympathize with your purpose?).
Spending time on research at a relevant library might convince your DM to lower the DC for such checks.