Misused header name, 'Content-Type'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.' #38
-
I got this error when sending filedata
Here is my code
|
Beta Was this translation helpful? Give feedback.
Answered by
gabrieldwight
May 18, 2023
Replies: 1 comment 20 replies
-
Hi @kasunf, The function above UploadFileDataAsync was for the resumable upload API, you will need to create an upload session Id first. I have tested it with image files only. The same steps should work with document files once you have created an upload session id. var uploadSessionId = await whatsAppBusinessClient.CreateResumableUploadSessionAsync(long fileLength, string fileType, string fileName);
var media = await whatsAppBusinessClient.UploadFileDataAsync(uploadSessionId, path, "application/pdf");
var url = await whatsAppBusinessClient.GetMediaUrlAsync(media.Id); Alternatively, you can use the uploadMediaFunction UploadMediaRequest uploadMediaRequest = new UploadMediaRequest();
uploadMediaRequest.File = path;
uploadMediaRequest.Type = "application/pdf";
var uploadMediaResult = await _whatsAppBusinessClient.UploadMediaAsync(uploadMediaRequest);
var url = await whatsAppBusinessClient.GetMediaUrlAsync(media.Id); |
Beta Was this translation helpful? Give feedback.
20 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my side, it is working with the MAUI you sent using the file picker API