title: How can I query user Azure AD attributes containing hyphens?
body: <p>There are Azure AD attributes for users whose names include hyphens. For example, <code>msDS-cloudExtensionAttribute1</code> or <code>msDS-principalName</code>. However, if I attempt to query those from Microsoft Graph in a <code>$select</code> or <code>$filter</code>, I get errors:</p>
  
  <pre><code>https://graph.microsoft.com/v1.0/users/?$select=id,msDS-principalName
  
  {
      "error": {
          "code": "BadRequest",
          "message": "Parsing Select and Expand failed.",
          "innerError": {
              "request-id": "...",
              "date": "..."
          }
      }
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>https://graph.microsoft.com/v1.0/users/?$filter=msDS-principalName eq 'abc'
  
  {
      "error": {
          "code": "BadRequest",
          "message": "Invalid filter clause",
          "innerError": {
              "request-id": "...",
              "date": "..."
          }
      }
  }
  </code></pre>
  
  <p>I can't find any documentation about escaping hyphens or otherwise successfully querying such attributes.</p>
  
  <p>Things that don't work:</p>
  
  <ol>
  <li>Escaping as <code>%2D</code></li>
  <li>Escaping with backslash</li>
  <li>Omitting the hyphen</li>
  </ol>