How update SharePoint Event ItemList BannerUrl using Graph API?

Mateus Ferreira 5 Reputation points
2024-06-28T11:59:58.1833333+00:00

I need to update the cover image of Events (ListItem Event) on SharePoint using the Graph API. I'm using APP ONLY ACCESS mode for authentication with this endpoint:

https://login.microsoftonline.com/{{tenant_id}}/oauth2/v2.0/token

My Application has the "Sites.Manage.All" scope.

When I call the endpoint to update or create an event, if I include the "BannerUrl" field, I always get the following error:

{
    "error": {
        "code": "generalException",
        "message": "General exception while processing",
        "innerError": {
            "date": "2024-06-28T11:50:07",
            "request-id": "a7f573a1-f7e9-49b8-9e0c-160a1d68cbf7",
            "client-request-id": "a7f573a1-f7e9-49b8-9e0c-160a1d68cbf7"
        }
    }
}

My request:

POST /v1.0/sites/{{site_id}}/lists/{{list_id}}/items HTTP/1.1
Host: graph.microsoft.com
Content-Type: application/json
Authorization: Bearer 
Content-Length: 507
{
    "fields": {
        "Title": "Example",
        "EventDate": "2024-07-15 09:00:00+00:00",
        "EndDate": "2024-07-15 17:00:00+00:00",
        "Category": "Example",
        "Description": "Hello world",
        "Location": "Avenida Paulista, 1000 - Bela Vista, São Paulo, SP 01313-000, Brazil",
        "fAllDayEvent": true,
        "BannerUrl": "https://image.jpg"
    }
}

If I set the field as NULL, it removes the current cover image. But when I try to pass a value, it doesn't work. How can I resolve this?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,200 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,108 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. AllenXu-MSFT 17,666 Reputation points Microsoft Vendor
    2024-07-01T05:36:06.4033333+00:00

    Hi @Mateus Ferreira,

    You need to use the PATCH method and include the BannerUrl property in the request body.

    PATCH https://graph.microsoft.com/v1.0/sites/{{siteId}}/lists/{{listId}}/items/{{itemId}}
    Content-Type: application/json
    {
        "fields": {
            "BannerImageUrl": "https://image.jpg"
        }
    }
    

    If the answer is helpful, please click "Accept as 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.


  2. Mateus Ferreira 5 Reputation points
    2024-07-01T12:15:42.6833333+00:00

    It didn't work, the request is executed successfully, but it doesn't reflect anything in the Event in sharepoint
    User's image

    I believe there are two fields, BannerImageUrl, and BannerUrl. BannerUrl seems to be the correct one, but I always get an error when I try to define this field
    User's image

    0 comments No comments