microsoftgraph / msgraph-sdk-serviceissues

Tracks service issues for follow up.
5 stars 0 forks source link

Unable to add ReferenceAttachment to Message #122

Open mpjones84 opened 4 years ago

mpjones84 commented 4 years ago

Describe the bug After creating a message you cannot attach a ReferenceAttachment to it as it is missing key properties such as SourceUrl

To Reproduce Create your message using the client

           var message = new Message
            {
                Body = new ItemBody
                {
                    Content = messageBody,
                    ContentType = BodyType.Html
                },

                Subject = subject,
                ToRecipients = to,
                From = from,
                ReplyTo = from.ToSingletonList()
            };
                var messageResponse = await _graphServiceClient.Users[_msGraphApiSettings.UserAdminId].Messages.Request().AddAsync(message);

Add a ReferenceAttachment to it

 await _graphServiceClient.Users[_msGraphApiSettings.UserAdminId].Messages[messageResponse.Id].Attachments
                    .Request()
                    .AddAsync(attachment);

Expected behavior Attachment made, as native api call.

Screenshots

{
  "error": {
    "code": "ErrorInvalidProperty",
    "message": "The property 'SourceUrl' is required when creating the entity.",
    "innerError": {
      "request-id": "156e828d-e028-4093-900b-c2d768d393e1",
      "date": "2020-02-19T18:41:41"
    }
  }
}

Client version 1.21.0

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

AB#7271

peombwa commented 4 years ago

Please share the following to help us understand the issue:

peombwa commented 4 years ago

Also, to set a SourceUrl on an attachment, use our beta library Microsoft.Graph.Beta instead of the v1.0 (Microsoft.Graph).

We don't know when it will go to v1.0.

mpjones84 commented 4 years ago

Sure

Request (shows old oath tokens)

curl -H "Host: graph.microsoft.com" -H "SdkVersion: Graph-dotnet-1.19.0" -H "FeatureFlag: 0000004F" -H "Cache-Control: no-store, no-cache" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IlR5SWlKc0VJZVBfY19aR05xTGxFZUdkUVlvS2RYS0RqRDZZU3RYWXJDNDAiLCJhbGciOiJSUzI1NiIsIng1dCI6IkhsQzBSMTJza3hOWjFXUXdtak9GXzZ0X3RERSIsImtpZCI6IkhsQzBSMTJza3hOWjFXUXdtak9GXzZ0X3RERSJ9.e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1BrnS3Tjdw2-j1rcIzNqd0gQNzLnZ2tR2R0LCG4RWlPqo5xEplDJQ3lcSd8LX75Zrqp1YF4yFmSYZVX0nUHO8miqKUZo4afH3_dCHxx79H9SPbZOSqmafzjXZ5HzGX10znwrcTngsUlL9d8d2RGg" -H "Request-Id: |3bbcdac7-4cf367d19928a396.7." -H "Content-Type: application/json" --data-binary '{"lastModifiedDateTime":"2020-02-21T10:32:42+00:00","name":"Mark Jones CV.docx","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","size":24313,"isInline":false,"id":"01YVVF4OVWSR6J2QU3XZHY2NLMBS5OHT4Z","@odata.type":"#microsoft.graph.referenceAttachment"}' --compressed https://graph.microsoft.com/v1.0/users/0d5436d0-8627-421a-8161-bdd64bc1293b/messages/AAMkAGJhMWVjYWRmLTFlNzYtNDQwNi1iMTFlLTM0NjM4OTRiZTRkZQBGAAAAAAAMX83-GYp_QKUu3sZG0R3PBwDXgoux8jeLSLH32me2lRzeAAAAAAEPAADXgoux8jeLSLH32me2lRzeAAFUAXreAAA=/attachments
 var infoUser = await _onedriveService.GetUser(_msGraphApiSettings.UserInfoId);
                    var attachment = new ReferenceAttachment
                    {
                        Name = uploadedFile.ItemResponse.Name,
                        Id = uploadedFile.ItemResponse.Id,
                        IsInline = false,
                        LastModifiedDateTime = uploadedFile.ItemResponse.LastModifiedDateTime,
                        Size = (int?)uploadedFile.ItemResponse.Size,
                        ContentType = uploadedFile.ItemResponse.File.MimeType
                    };

There is no sourceUrl in the current model, I can see them on the beta, but I cannot get that to work along side the current version, due to this issue https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet/issues/72

It seems to me that the client nuget packages doesn't have the same models as required by the api, so you have a mis match between client and server somewhere.

mpjones84 commented 4 years ago

Hi

Is there any update on this issue?

MIchaelMainer commented 4 years ago

@svpsiva Do we have a timeline for getting reference attachment onto v1.0?

ZuperKeurZ commented 3 years ago

Running into the same problem.

Can we do something to help resolve this issue?

maisarissi commented 3 years ago

Hi @abheek-das. Can you help us with this issue? The SourceUrl parameter shouldn't be required in v1.0 as per current documentation and metadata.

petrhollayms commented 6 months ago

Thank you for reporting this issue. This appears to be an issue or limitation with the service APIs. Unfortunately, as the Microsoft Graph SDK team, we do not have ownership of the APIs that are causing you issues. We invite you to create a question about the service API to Microsoft Q&A and tagged with one of the [microsoft-graph-*] tags, that way it will get routed to the appropriate team for them to triage:

https://aka.ms/msgraphsupport or directly https://aka.ms/askgraph

For now, we will close the issue on our side but feel free to open it in the relevant repository if you think the issue is specific to SDK. Please let us know if this helps!

Note: We will close this repository on April 19, 2024.