Is it possible to make REST calls from Graph Api sdk using GraphClient

Parth Jani 90 Reputation points
2023-07-08T11:33:23.1166667+00:00

Hello

I was trying to make this SharePoint Rest call using Graph sdk:
https://tenant.sharepoint.com/sites/SiteInfi2022/_api/web/lists/getbytitle('hen')/items(1)?$expand=AttachmentFiles

refer code below :


            var requestInformation = new RequestInformation()
            {
                HttpMethod = Method.GET,
                URI = new Uri("https://tenant.sharepoint.com/sites/SiteInfi2022/_api/web/lists/getbytitle('hen')/items(1)?$expand=AttachmentFiles")
               

            };
           requestInformation.Headers.Add("Accept", "application/xml");
            requestInformation.Headers.Add("Content-Type", "application/xml");
            requestInformation.Headers.Add("Prefer", "HonorNonIndexedQueriesWarningMayFailRandomly");
        

            var nativeResponseHadnler = new NativeResponseHandler();
            requestInformation.SetResponseHandler(nativeResponseHadnler);
            var asdfsf = GraphClient.RequestAdapter.ConvertToNativeRequestAsync<HttpRequestMessage>(requestInformation); // this will be authenticated with the authenticationprovider




            var response = nativeResponseHadnler.Value as HttpResponseMessage;
            if (response.IsSuccessStatusCode)
            {
                string result = response.Content.ReadAsStringAsync().Result;
            }

But it's not fetching any results , content is null.
I am using Request Adapter which was Replaced by HTTProvider.
Please let me know how can i execute this api call using graph client

Thanks

Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Anonymous
    2023-07-10T07:24:22.3066667+00:00

    HI @Parth Jani,

    Thanks for letting us know your user experience. According to your case description, I do understand how frustrated you are now.

    Graph sdk can only be used for verification of Graph API, theoretically it cannot verify Sharepoint rest API.

    Maybe you can try CSOM to call Sharepoint rest api, or power shell

    Sharepoint api :https://www.codesharepoint.com/rest-api/get-all-attachments-from-list-item-in-sharepoint-using-rest-api

    CSOM :https://www.codesharepoint.com/csom/get-all-attachments-from-list-item-in-sharepoint-using-csom


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.