{"id":6645,"date":"2019-12-18T20:10:54","date_gmt":"2019-12-18T20:10:54","guid":{"rendered":"http:\/\/blogs.aaddevsup.xyz\/?p=6645"},"modified":"2019-12-18T20:10:56","modified_gmt":"2019-12-18T20:10:56","slug":"graph-query-to-get-b2b-user-using-user-principal-name-upn","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2019\/12\/graph-query-to-get-b2b-user-using-user-principal-name-upn\/","title":{"rendered":"Graph Query to get B2B user using User Principal Name (UPN)"},"content":{"rendered":"\n

If you are using Microsoft Graph API Query to fetch B2B user using UPN, and experiencing below shown error:<\/p>\n\n\n\n

Query<\/strong>: https:\/\/graph.microsoft.com\/v1.0\/users\/example_gmail.com#EXT#@example.onmicrosoft.com<\/p>\n\n\n\n

Response:<\/strong><\/p>\n\n\n\n

\n
\n

{<\/p>\n<\/div><\/div>\n\n\n\n

  ‘error’: {<\/p>\n\n\n\n

    ‘code’:\n‘Request_ResourceNotFound’,<\/p>\n\n\n\n

    ‘message’: ‘Resource \u2018*******\u2019\ndoes not exist or one of its queried reference-property objects are not\npresent.’,<\/p>\n\n\n\n

    ‘innerError’: {<\/p>\n\n\n\n

      ‘request-id’:\n‘8f390389-b9c6-4f6b-93ba-c531b3d7d595’,<\/p>\n\n\n\n

      ‘date’:\n‘2019-12-05T23:55:40’<\/p>\n\n\n\n

    }<\/p>\n\n\n\n

  }<\/p>\n\n\n\n

}<\/p>\n<\/div><\/div>\n\n\n\n

Well, here is the fix:<\/p>\n\n\n\n

You will need to encode the URL<\/strong> request. Reason, you are experiencing the error is because, ‘#<\/strong>‘ sign is treated as a special character in the URL. So ‘#<\/strong>‘ must be URL-encoded<\/a> otherwise everything after it will be treated as a fragment and will not get sent over the wire. If you replace the ‘#<\/strong>‘ sign with \u2018%23<\/strong>\u2019, it should work.  <\/p>\n\n\n\n

Working Query Format : <\/strong>https:\/\/graph.microsoft.com\/v1.0\/users\/example_gmail.com%23<\/strong>EXT%23<\/strong>@example.onmicrosoft.com <\/p>\n","protected":false},"excerpt":{"rendered":"

If you are using Microsoft Graph API Query to fetch B2B user using UPN, and experiencing below shown error: Query: https:\/\/graph.microsoft.com\/v1.0\/users\/example_gmail.com#EXT#@example.onmicrosoft.com Response: {   ‘error’: {     ‘code’: ‘Request_ResourceNotFound’,     ‘message’: ‘Resource \u2018*******\u2019 does not exist or one of its queried reference-property objects are not present.’,     ‘innerError’: {       ‘request-id’: ‘8f390389-b9c6-4f6b-93ba-c531b3d7d595’,       ‘date’: ‘2019-12-05T23:55:40’     }   } } Well, here is the fix: You will need to encode…<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[188,10],"tags":[189,100,135],"class_list":["post-6645","post","type-post","status-publish","format-standard","hentry","category-b2b","category-microsoftgraph","tag-b2b","tag-microsoft-graph","tag-users"],"_links":{"self":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/6645"}],"collection":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/comments?post=6645"}],"version-history":[{"count":10,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/6645\/revisions"}],"predecessor-version":[{"id":6739,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/6645\/revisions\/6739"}],"wp:attachment":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/media?parent=6645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/categories?post=6645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/tags?post=6645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}