Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Type error on PostFeedItemWithAttachmentAsync #382

Open
busbina opened this issue Jul 24, 2020 · 0 comments
Open

Content-Type error on PostFeedItemWithAttachmentAsync #382

busbina opened this issue Jul 24, 2020 · 0 comments

Comments

@busbina
Copy link

busbina commented Jul 24, 2020

I am getting the following error:

ForceException: Binary data included but file attachment information is missing. If providing rich JSON/XML input in multipart REST, make sure to include Content-Type header in the part.

when I call PostFeedItemWithAttachmentAsync.

Here is my code:

        var instanceUrl = auth.InstanceUrl;
        var accessToken = auth.AccessToken;
        var apiVersion = auth.ApiVersion;
        var chatter = new ChatterClient(instanceUrl, accessToken, apiVersion);
        var me = chatter.MeAsync<UserDetail>().Result;
        var input = new ObjectFeedItemInput();
        input.ObjectId = me.id;

        var memoryStream = new MemoryStream();
        stream.CopyTo(memoryStream);
        var bytes = memoryStream.ToArray();

        var result = await chatter.PostFeedItemWithAttachmentAsync<FeedItem>(input, bytes, "319051.jpg");

I turned on the system.net diagnostics and can see these headers in my logs.

Content-Type: application/octet-stream
Content-Disposition: form-data; name="feedElementFileUpload"; filename="319051.jpg"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant