question

YoungjooYang-6448 avatar image
0 Votes"
YoungjooYang-6448 asked Miles6787-3073 commented

Graph API - Daemon Web 404 Error

Dear Any,

I am testing the Java project I downloaded from https://github.com/Azure-Samples/ms-identity-java-daemon/archive/master.zip.
The sample program is working well, from which the used url is "https://graph.microsoft.com/v1.0/user".

But when I change the url to https://graph.microsoft.com/v1.0/users/admin@acbconfroom.onmicrosoft.com/contacts,
it has the error like this "Connection returned HTTP code: 404 with message: Not Found".
(admin@acbconfroom.onmicrosoft.com is my Azure AD email.)

Of course, I've added Contacts.Read and Contacts.ReadWrite as API permissions for changed url, and then they are Granted for my API.

I want to know it is possible to access the changed url(https://graph.microsoft.com/v1.0/users/admin@acbconfroom.onmicrosoft.com/contacts)
as a background service without sign in.

Please give me some hint or solution to access this url!!!

FYI, I succeeded in accessing this url in the graph-explorer.

Best regards,
Y.J.Yang

microsoft-graph-sdkazure-ad-app-registrationazure-ad-graphazure-ad-msal
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi ,

Actually I am using https://graph.microsoft.com/v1.0/me/contacts api form code but the error is 404 not found and the same api if i'm accesing through microsft graph explorer api then i can fetch my contacts. But i need to know how can i call from my code specifically from angular(in TS file). Even on suggestion i have tried to see my jwt token using jwt.io . i think all things are correct in jwt but i am getting invalid signature error in token, you can preview in this below image. Can you pls help with me this I just want to access all contacts of signed-in users??

Thanks in advance.


176291-image.png


0 Votes 0 ·
image.png (101.6 KiB)

I'm not sure how you're making you API call, but you shouldn't be getting 404s at that endpoint. But you can use leverage the graph client package and

const {
    Client
} = require("@microsoft/microsoft-graph-client");

const options = {
    authProvider,
};

const client = Client.init(options);

let contacts = await client.api('/me/contacts')
    .get();


Configuring the authProvider will be dependent on which provider you elect; you can find more details on https://docs.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=Javascript.

0 Votes 0 ·

Hi, I have tested mentioned script on best triple monitor setup but it showing the issue. Also my developer checked it on another tester device but he was facing issue. After research he updated the script with some coding and boom the script start working. As java some time show issue if there is a minor error in the code so kindly dually check your java script.


0 Votes 0 ·

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered ryanchill commented

Hi @YoungjooYang-6448,

I've updated the tags on your question to get more visibility. By no means am I an expert on Graph but to answer your question, you should be able to access a user's contacts.

Since using the userPrincipalName in the Graph Explorer was successful, have you tried using actual user's id to see if that works. If that's not successful, then it's either the delegate permissions of your app registration or scope variable used to generate the token. Verify in jwt.io that the token has the appropriate scopes.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Ryanchill,

I think your information is very helpful for me to understand what this situation is.
Specially, I can analyze my access token exactly in jwt.io you informed me of.
By the way I found out this issue is related to the api, which is not proper for a background service.
So after using "/groups/{id}/members" api, I can access the resource as a background service.

Anyway thank you for your kind answer.

Warm regards,
Y.J.Yang


1 Vote 1 ·

Glad you were able to find a solution @YoungjooYang-6448 😊.

0 Votes 0 ·